discouraged.h 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. /* This file contains definitions for discouraged features. When you
  2. discourage something, move it here when that is feasible.
  3. A discouraged feature is one that shouldn't be used in new code
  4. since we have a better alternative now. However, there is nothing
  5. wrong with using the old feature, so it is OK to continue to use
  6. it.
  7. Eventually, discouraged features can be deprecated since removing
  8. them will make Guile simpler.
  9. */
  10. #ifndef SCM_DISCOURAGED_H
  11. #define SCM_DISCOURAGED_H
  12. /* Copyright (C) 2004, 2006 Free Software Foundation, Inc.
  13. *
  14. * This library is free software; you can redistribute it and/or
  15. * modify it under the terms of the GNU Lesser General Public
  16. * License as published by the Free Software Foundation; either
  17. * version 2.1 of the License, or (at your option) any later version.
  18. *
  19. * This library is distributed in the hope that it will be useful,
  20. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  21. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  22. * Lesser General Public License for more details.
  23. *
  24. * You should have received a copy of the GNU Lesser General Public
  25. * License along with this library; if not, write to the Free Software
  26. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  27. */
  28. #include "libguile/__scm.h"
  29. #if SCM_ENABLE_DISCOURAGED == 1
  30. /* Discouraged because they do not follow the naming convention. That
  31. is, they end in "P" but return a C boolean. Also, SCM_BOOLP
  32. evaluates its argument twice.
  33. */
  34. #define SCM_FALSEP scm_is_false
  35. #define SCM_NFALSEP scm_is_true
  36. #define SCM_BOOLP scm_is_bool
  37. #define SCM_EQ_P scm_is_eq
  38. /* Convert from a C boolean to a SCM boolean value */
  39. #define SCM_BOOL scm_from_bool
  40. /* Convert from a C boolean to a SCM boolean value and negate it */
  41. #define SCM_NEGATE_BOOL(f) scm_from_bool(!(f))
  42. /* SCM_BOOL_NOT returns the other boolean.
  43. * The order of ^s here is important for Borland C++ (!?!?!)
  44. */
  45. #define SCM_BOOL_NOT(x) (SCM_PACK (SCM_UNPACK (x) \
  46. ^ (SCM_UNPACK (SCM_BOOL_T) \
  47. ^ SCM_UNPACK (SCM_BOOL_F))))
  48. /* scm_to_int, scm_from_int are the official functions to do the job,
  49. but there is nothing wrong with using scm_num2int, etc.
  50. These could be trivially defined via macros, but we leave them as
  51. functions since existing code may take their addresses.
  52. */
  53. SCM_API SCM scm_short2num (short n);
  54. SCM_API SCM scm_ushort2num (unsigned short n);
  55. SCM_API SCM scm_int2num (int n);
  56. SCM_API SCM scm_uint2num (unsigned int n);
  57. SCM_API SCM scm_long2num (long n);
  58. SCM_API SCM scm_ulong2num (unsigned long n);
  59. SCM_API SCM scm_size2num (size_t n);
  60. SCM_API SCM scm_ptrdiff2num (scm_t_ptrdiff n);
  61. SCM_API short scm_num2short (SCM num, unsigned long int pos,
  62. const char *s_caller);
  63. SCM_API unsigned short scm_num2ushort (SCM num, unsigned long int pos,
  64. const char *s_caller);
  65. SCM_API int scm_num2int (SCM num, unsigned long int pos,
  66. const char *s_caller);
  67. SCM_API unsigned int scm_num2uint (SCM num, unsigned long int pos,
  68. const char *s_caller);
  69. SCM_API long scm_num2long (SCM num, unsigned long int pos,
  70. const char *s_caller);
  71. SCM_API unsigned long scm_num2ulong (SCM num, unsigned long int pos,
  72. const char *s_caller);
  73. SCM_API scm_t_ptrdiff scm_num2ptrdiff (SCM num, unsigned long int pos,
  74. const char *s_caller);
  75. SCM_API size_t scm_num2size (SCM num, unsigned long int pos,
  76. const char *s_caller);
  77. #if SCM_SIZEOF_LONG_LONG != 0
  78. SCM_API SCM scm_long_long2num (long long sl);
  79. SCM_API SCM scm_ulong_long2num (unsigned long long sl);
  80. SCM_API long long scm_num2long_long (SCM num, unsigned long int pos,
  81. const char *s_caller);
  82. SCM_API unsigned long long scm_num2ulong_long (SCM num, unsigned long int pos,
  83. const char *s_caller);
  84. #endif
  85. SCM_API SCM scm_make_real (double x);
  86. SCM_API double scm_num2dbl (SCM a, const char * why);
  87. SCM_API SCM scm_float2num (float n);
  88. SCM_API SCM scm_double2num (double n);
  89. /* The next two are implemented in numbers.c since they use features
  90. only available there.
  91. */
  92. SCM_API float scm_num2float (SCM num, unsigned long int pos,
  93. const char *s_caller);
  94. SCM_API double scm_num2double (SCM num, unsigned long int pos,
  95. const char *s_caller);
  96. SCM_API SCM scm_make_complex (double x, double y);
  97. /* Discouraged because they don't make the encoding explicit.
  98. */
  99. SCM_API SCM scm_mem2symbol (const char *mem, size_t len);
  100. SCM_API SCM scm_mem2uninterned_symbol (const char *mem, size_t len);
  101. SCM_API SCM scm_str2symbol (const char *str);
  102. SCM_API SCM scm_take_str (char *s, size_t len);
  103. SCM_API SCM scm_take0str (char *s);
  104. SCM_API SCM scm_mem2string (const char *src, size_t len);
  105. SCM_API SCM scm_str2string (const char *src);
  106. SCM_API SCM scm_makfrom0str (const char *src);
  107. SCM_API SCM scm_makfrom0str_opt (const char *src);
  108. /* Discouraged because scm_c_make_string has a better name and is more
  109. consistent with make-string.
  110. */
  111. SCM_API SCM scm_allocate_string (size_t len);
  112. /* Discouraged because scm_is_symbol has a better name,
  113. */
  114. #define SCM_SYMBOLP scm_is_symbol
  115. /* Discouraged because the alternatives have the better names.
  116. */
  117. #define SCM_SYMBOL_FUNC scm_symbol_fref
  118. #define SCM_SET_SYMBOL_FUNC scm_symbol_fset_x
  119. #define SCM_SYMBOL_PROPS scm_symbol_pref
  120. #define SCM_SET_SYMBOL_PROPS scm_symbol_pset_x
  121. /* Discouraged because there are better ways.
  122. */
  123. #define SCM_SYMBOL_HASH scm_i_symbol_hash
  124. #define SCM_SYMBOL_INTERNED_P(X) scm_i_symbol_is_interned
  125. /* Discouraged because they evaluated their arguments twice and/or
  126. don't fit the naming scheme.
  127. */
  128. #define SCM_CONSP(x) (scm_is_pair (x))
  129. #define SCM_NCONSP(x) (!SCM_CONSP (x))
  130. #define SCM_NULLP(x) (scm_is_null (x))
  131. #define SCM_NNULLP(x) (!scm_is_null (x))
  132. /* Discouraged because they are just strange.
  133. */
  134. SCM_API SCM scm_make_keyword_from_dash_symbol (SCM symbol);
  135. SCM_API SCM scm_keyword_dash_symbol (SCM keyword);
  136. /* Discouraged because it does not state what encoding S is in.
  137. */
  138. SCM_API SCM scm_c_make_keyword (const char *s);
  139. /* Discouraged because the 'internal' and 'thread' moniker is
  140. confusing.
  141. */
  142. #define scm_internal_select scm_std_select
  143. #define scm_thread_sleep scm_std_sleep
  144. #define scm_thread_usleep scm_std_usleep
  145. void scm_i_init_discouraged (void);
  146. #endif /* SCM_ENABLE_DISCOURAGED == 1 */
  147. #endif /* SCM_DISCOURAGED_H */