deprecated.c 40 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507
  1. /* This file contains definitions for deprecated features. When you
  2. deprecate something, move it here when that is feasible.
  3. */
  4. /* Copyright (C) 2003, 2004, 2006, 2008 Free Software Foundation, Inc.
  5. *
  6. * This library is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Lesser General Public License
  8. * as published by the Free Software Foundation; either version 3 of
  9. * the License, or (at your option) any later version.
  10. *
  11. * This library is distributed in the hope that it will be useful, but
  12. * WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public
  17. * License along with this library; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  19. * 02110-1301 USA
  20. */
  21. #ifdef HAVE_CONFIG_H
  22. # include <config.h>
  23. #endif
  24. #include "libguile/_scm.h"
  25. #include "libguile/async.h"
  26. #include "libguile/deprecated.h"
  27. #include "libguile/discouraged.h"
  28. #include "libguile/deprecation.h"
  29. #include "libguile/snarf.h"
  30. #include "libguile/validate.h"
  31. #include "libguile/strings.h"
  32. #include "libguile/srfi-13.h"
  33. #include "libguile/modules.h"
  34. #include "libguile/eval.h"
  35. #include "libguile/smob.h"
  36. #include "libguile/procprop.h"
  37. #include "libguile/vectors.h"
  38. #include "libguile/hashtab.h"
  39. #include "libguile/struct.h"
  40. #include "libguile/variable.h"
  41. #include "libguile/fluids.h"
  42. #include "libguile/ports.h"
  43. #include "libguile/eq.h"
  44. #include "libguile/read.h"
  45. #include "libguile/strports.h"
  46. #include "libguile/smob.h"
  47. #include "libguile/alist.h"
  48. #include "libguile/keywords.h"
  49. #include "libguile/feature.h"
  50. #include <stdio.h>
  51. #include <string.h>
  52. #if (SCM_ENABLE_DEPRECATED == 1)
  53. /* From print.c: Internal symbol names of isyms. Deprecated in guile 1.7.0 on
  54. * 2004-04-22. */
  55. char *scm_isymnames[] =
  56. {
  57. "#@<deprecated>"
  58. };
  59. /* From eval.c: Error messages of the evaluator. These were deprecated in
  60. * guile 1.7.0 on 2003-06-02. */
  61. const char scm_s_expression[] = "missing or extra expression";
  62. const char scm_s_test[] = "bad test";
  63. const char scm_s_body[] = "bad body";
  64. const char scm_s_bindings[] = "bad bindings";
  65. const char scm_s_variable[] = "bad variable";
  66. const char scm_s_clauses[] = "bad or missing clauses";
  67. const char scm_s_formals[] = "bad formals";
  68. SCM_REGISTER_PROC(s_substring_move_left_x, "substring-move-left!", 5, 0, 0, scm_substring_move_x);
  69. SCM_REGISTER_PROC(s_substring_move_right_x, "substring-move-right!", 5, 0, 0, scm_substring_move_x);
  70. SCM
  71. scm_wta (SCM arg, const char *pos, const char *s_subr)
  72. {
  73. if (!s_subr || !*s_subr)
  74. s_subr = NULL;
  75. if ((~0x1fL) & (long) pos)
  76. {
  77. /* error string supplied. */
  78. scm_misc_error (s_subr, pos, scm_list_1 (arg));
  79. }
  80. else
  81. {
  82. /* numerical error code. */
  83. scm_t_bits error = (scm_t_bits) pos;
  84. switch (error)
  85. {
  86. case SCM_ARGn:
  87. scm_wrong_type_arg (s_subr, 0, arg);
  88. case SCM_ARG1:
  89. scm_wrong_type_arg (s_subr, 1, arg);
  90. case SCM_ARG2:
  91. scm_wrong_type_arg (s_subr, 2, arg);
  92. case SCM_ARG3:
  93. scm_wrong_type_arg (s_subr, 3, arg);
  94. case SCM_ARG4:
  95. scm_wrong_type_arg (s_subr, 4, arg);
  96. case SCM_ARG5:
  97. scm_wrong_type_arg (s_subr, 5, arg);
  98. case SCM_ARG6:
  99. scm_wrong_type_arg (s_subr, 6, arg);
  100. case SCM_ARG7:
  101. scm_wrong_type_arg (s_subr, 7, arg);
  102. case SCM_WNA:
  103. scm_wrong_num_args (arg);
  104. case SCM_OUTOFRANGE:
  105. scm_out_of_range (s_subr, arg);
  106. case SCM_NALLOC:
  107. scm_memory_error (s_subr);
  108. default:
  109. /* this shouldn't happen. */
  110. scm_misc_error (s_subr, "Unknown error", SCM_EOL);
  111. }
  112. }
  113. return SCM_UNSPECIFIED;
  114. }
  115. /* Module registry
  116. */
  117. /* We can't use SCM objects here. One should be able to call
  118. SCM_REGISTER_MODULE from a C++ constructor for a static
  119. object. This happens before main and thus before libguile is
  120. initialized. */
  121. struct moddata {
  122. struct moddata *link;
  123. char *module_name;
  124. void *init_func;
  125. };
  126. static struct moddata *registered_mods = NULL;
  127. void
  128. scm_register_module_xxx (char *module_name, void *init_func)
  129. {
  130. struct moddata *md;
  131. scm_c_issue_deprecation_warning
  132. ("`scm_register_module_xxx' is deprecated. Use extensions instead.");
  133. /* XXX - should we (and can we) DEFER_INTS here? */
  134. for (md = registered_mods; md; md = md->link)
  135. if (!strcmp (md->module_name, module_name))
  136. {
  137. md->init_func = init_func;
  138. return;
  139. }
  140. md = (struct moddata *) malloc (sizeof (struct moddata));
  141. if (md == NULL)
  142. {
  143. fprintf (stderr,
  144. "guile: can't register module (%s): not enough memory",
  145. module_name);
  146. return;
  147. }
  148. md->module_name = module_name;
  149. md->init_func = init_func;
  150. md->link = registered_mods;
  151. registered_mods = md;
  152. }
  153. SCM_DEFINE (scm_registered_modules, "c-registered-modules", 0, 0, 0,
  154. (),
  155. "Return a list of the object code modules that have been imported into\n"
  156. "the current Guile process. Each element of the list is a pair whose\n"
  157. "car is the name of the module, and whose cdr is the function handle\n"
  158. "for that module's initializer function. The name is the string that\n"
  159. "has been passed to scm_register_module_xxx.")
  160. #define FUNC_NAME s_scm_registered_modules
  161. {
  162. SCM res;
  163. struct moddata *md;
  164. res = SCM_EOL;
  165. for (md = registered_mods; md; md = md->link)
  166. res = scm_cons (scm_cons (scm_from_locale_string (md->module_name),
  167. scm_from_ulong ((unsigned long) md->init_func)),
  168. res);
  169. return res;
  170. }
  171. #undef FUNC_NAME
  172. SCM_DEFINE (scm_clear_registered_modules, "c-clear-registered-modules", 0, 0, 0,
  173. (),
  174. "Destroy the list of modules registered with the current Guile process.\n"
  175. "The return value is unspecified. @strong{Warning:} this function does\n"
  176. "not actually unlink or deallocate these modules, but only destroys the\n"
  177. "records of which modules have been loaded. It should therefore be used\n"
  178. "only by module bookkeeping operations.")
  179. #define FUNC_NAME s_scm_clear_registered_modules
  180. {
  181. struct moddata *md1, *md2;
  182. SCM_CRITICAL_SECTION_START;
  183. for (md1 = registered_mods; md1; md1 = md2)
  184. {
  185. md2 = md1->link;
  186. free (md1);
  187. }
  188. registered_mods = NULL;
  189. SCM_CRITICAL_SECTION_END;
  190. return SCM_UNSPECIFIED;
  191. }
  192. #undef FUNC_NAME
  193. void
  194. scm_remember (SCM *ptr)
  195. {
  196. scm_c_issue_deprecation_warning ("`scm_remember' is deprecated. "
  197. "Use the `scm_remember_upto_here*' family of functions instead.");
  198. }
  199. SCM
  200. scm_protect_object (SCM obj)
  201. {
  202. scm_c_issue_deprecation_warning ("`scm_protect_object' is deprecated. "
  203. "Use `scm_gc_protect_object' instead.");
  204. return scm_gc_protect_object (obj);
  205. }
  206. SCM
  207. scm_unprotect_object (SCM obj)
  208. {
  209. scm_c_issue_deprecation_warning ("`scm_unprotect_object' is deprecated. "
  210. "Use `scm_gc_unprotect_object' instead.");
  211. return scm_gc_unprotect_object (obj);
  212. }
  213. SCM_SYMBOL (scm_sym_app, "app");
  214. SCM_SYMBOL (scm_sym_modules, "modules");
  215. static SCM module_prefix = SCM_BOOL_F;
  216. static SCM make_modules_in_var;
  217. static SCM beautify_user_module_x_var;
  218. static SCM try_module_autoload_var;
  219. static void
  220. init_module_stuff ()
  221. {
  222. #define PERM(x) scm_permanent_object(x)
  223. if (module_prefix == SCM_BOOL_F)
  224. {
  225. module_prefix = PERM (scm_list_2 (scm_sym_app, scm_sym_modules));
  226. make_modules_in_var = PERM (scm_c_lookup ("make-modules-in"));
  227. beautify_user_module_x_var =
  228. PERM (scm_c_lookup ("beautify-user-module!"));
  229. try_module_autoload_var = PERM (scm_c_lookup ("try-module-autoload"));
  230. }
  231. }
  232. SCM
  233. scm_the_root_module ()
  234. {
  235. init_module_stuff ();
  236. scm_c_issue_deprecation_warning ("`scm_the_root_module' is deprecated. "
  237. "Use `scm_c_resolve_module (\"guile\")' "
  238. "instead.");
  239. return scm_c_resolve_module ("guile");
  240. }
  241. static SCM
  242. scm_module_full_name (SCM name)
  243. {
  244. init_module_stuff ();
  245. if (scm_is_eq (SCM_CAR (name), scm_sym_app))
  246. return name;
  247. else
  248. return scm_append (scm_list_2 (module_prefix, name));
  249. }
  250. SCM
  251. scm_make_module (SCM name)
  252. {
  253. init_module_stuff ();
  254. scm_c_issue_deprecation_warning ("`scm_make_module' is deprecated. "
  255. "Use `scm_c_define_module instead.");
  256. return scm_call_2 (SCM_VARIABLE_REF (make_modules_in_var),
  257. scm_the_root_module (),
  258. scm_module_full_name (name));
  259. }
  260. SCM
  261. scm_ensure_user_module (SCM module)
  262. {
  263. init_module_stuff ();
  264. scm_c_issue_deprecation_warning ("`scm_ensure_user_module' is deprecated. "
  265. "Use `scm_c_define_module instead.");
  266. scm_call_1 (SCM_VARIABLE_REF (beautify_user_module_x_var), module);
  267. return SCM_UNSPECIFIED;
  268. }
  269. SCM
  270. scm_load_scheme_module (SCM name)
  271. {
  272. init_module_stuff ();
  273. scm_c_issue_deprecation_warning ("`scm_load_scheme_module' is deprecated. "
  274. "Use `scm_c_resolve_module instead.");
  275. return scm_call_1 (SCM_VARIABLE_REF (try_module_autoload_var), name);
  276. }
  277. /* This is implemented in C solely for SCM_COERCE_OUTPORT ... */
  278. static void
  279. maybe_close_port (void *data, SCM port)
  280. {
  281. SCM except_set = (SCM) data;
  282. while (!scm_is_null (except_set))
  283. {
  284. SCM p = SCM_COERCE_OUTPORT (SCM_CAR (except_set));
  285. if (scm_is_eq (p, port))
  286. return;
  287. except_set = SCM_CDR (except_set);
  288. }
  289. scm_close_port (port);
  290. }
  291. SCM_DEFINE (scm_close_all_ports_except, "close-all-ports-except", 0, 0, 1,
  292. (SCM ports),
  293. "[DEPRECATED] Close all open file ports used by the interpreter\n"
  294. "except for those supplied as arguments. This procedure\n"
  295. "was intended to be used before an exec call to close file descriptors\n"
  296. "which are not needed in the new process. However it has the\n"
  297. "undesirable side effect of flushing buffers, so it's deprecated.\n"
  298. "Use port-for-each instead.")
  299. #define FUNC_NAME s_scm_close_all_ports_except
  300. {
  301. SCM p;
  302. SCM_VALIDATE_REST_ARGUMENT (ports);
  303. for (p = ports; !scm_is_null (p); p = SCM_CDR (p))
  304. SCM_VALIDATE_OPPORT (SCM_ARG1, SCM_COERCE_OUTPORT (SCM_CAR (p)));
  305. scm_c_port_for_each (maybe_close_port, ports);
  306. return SCM_UNSPECIFIED;
  307. }
  308. #undef FUNC_NAME
  309. SCM_DEFINE (scm_variable_set_name_hint, "variable-set-name-hint!", 2, 0, 0,
  310. (SCM var, SCM hint),
  311. "Do not use this function.")
  312. #define FUNC_NAME s_scm_variable_set_name_hint
  313. {
  314. SCM_VALIDATE_VARIABLE (1, var);
  315. SCM_VALIDATE_SYMBOL (2, hint);
  316. scm_c_issue_deprecation_warning
  317. ("'variable-set-name-hint!' is deprecated. Do not use it.");
  318. return SCM_UNSPECIFIED;
  319. }
  320. #undef FUNC_NAME
  321. SCM_DEFINE (scm_builtin_variable, "builtin-variable", 1, 0, 0,
  322. (SCM name),
  323. "Do not use this function.")
  324. #define FUNC_NAME s_scm_builtin_variable
  325. {
  326. SCM_VALIDATE_SYMBOL (1,name);
  327. scm_c_issue_deprecation_warning ("`builtin-variable' is deprecated. "
  328. "Use module system operations instead.");
  329. return scm_sym2var (name, SCM_BOOL_F, SCM_BOOL_T);
  330. }
  331. #undef FUNC_NAME
  332. SCM
  333. scm_makstr (size_t len, int dummy)
  334. {
  335. scm_c_issue_deprecation_warning
  336. ("'scm_makstr' is deprecated. Use 'scm_c_make_string' instead.");
  337. return scm_c_make_string (len, SCM_UNDEFINED);
  338. }
  339. SCM
  340. scm_makfromstr (const char *src, size_t len, int dummy SCM_UNUSED)
  341. {
  342. scm_c_issue_deprecation_warning ("`scm_makfromstr' is deprecated. "
  343. "Use `scm_from_locale_stringn' instead.");
  344. return scm_from_locale_stringn (src, len);
  345. }
  346. SCM
  347. scm_internal_with_fluids (SCM fluids, SCM values, SCM (*cproc) (), void *cdata)
  348. {
  349. scm_c_issue_deprecation_warning ("`scm_internal_with_fluids' is deprecated. "
  350. "Use `scm_c_with_fluids' instead.");
  351. return scm_c_with_fluids (fluids, values, cproc, cdata);
  352. }
  353. SCM
  354. scm_make_gsubr (const char *name, int req, int opt, int rst, SCM (*fcn)())
  355. {
  356. scm_c_issue_deprecation_warning
  357. ("`scm_make_gsubr' is deprecated. Use `scm_c_define_gsubr' instead.");
  358. return scm_c_define_gsubr (name, req, opt, rst, fcn);
  359. }
  360. SCM
  361. scm_make_gsubr_with_generic (const char *name,
  362. int req, int opt, int rst,
  363. SCM (*fcn)(), SCM *gf)
  364. {
  365. scm_c_issue_deprecation_warning
  366. ("`scm_make_gsubr_with_generic' is deprecated. "
  367. "Use `scm_c_define_gsubr_with_generic' instead.");
  368. return scm_c_define_gsubr_with_generic (name, req, opt, rst, fcn, gf);
  369. }
  370. SCM
  371. scm_create_hook (const char *name, int n_args)
  372. {
  373. scm_c_issue_deprecation_warning
  374. ("'scm_create_hook' is deprecated. "
  375. "Use 'scm_make_hook' and 'scm_c_define' instead.");
  376. {
  377. SCM hook = scm_make_hook (scm_from_int (n_args));
  378. scm_c_define (name, hook);
  379. return scm_permanent_object (hook);
  380. }
  381. }
  382. SCM_DEFINE (scm_sloppy_memq, "sloppy-memq", 2, 0, 0,
  383. (SCM x, SCM lst),
  384. "This procedure behaves like @code{memq}, but does no type or error checking.\n"
  385. "Its use is recommended only in writing Guile internals,\n"
  386. "not for high-level Scheme programs.")
  387. #define FUNC_NAME s_scm_sloppy_memq
  388. {
  389. scm_c_issue_deprecation_warning
  390. ("'sloppy-memq' is deprecated. Use 'memq' instead.");
  391. for(; scm_is_pair (lst); lst = SCM_CDR(lst))
  392. {
  393. if (scm_is_eq (SCM_CAR (lst), x))
  394. return lst;
  395. }
  396. return lst;
  397. }
  398. #undef FUNC_NAME
  399. SCM_DEFINE (scm_sloppy_memv, "sloppy-memv", 2, 0, 0,
  400. (SCM x, SCM lst),
  401. "This procedure behaves like @code{memv}, but does no type or error checking.\n"
  402. "Its use is recommended only in writing Guile internals,\n"
  403. "not for high-level Scheme programs.")
  404. #define FUNC_NAME s_scm_sloppy_memv
  405. {
  406. scm_c_issue_deprecation_warning
  407. ("'sloppy-memv' is deprecated. Use 'memv' instead.");
  408. for(; scm_is_pair (lst); lst = SCM_CDR(lst))
  409. {
  410. if (! scm_is_false (scm_eqv_p (SCM_CAR (lst), x)))
  411. return lst;
  412. }
  413. return lst;
  414. }
  415. #undef FUNC_NAME
  416. SCM_DEFINE (scm_sloppy_member, "sloppy-member", 2, 0, 0,
  417. (SCM x, SCM lst),
  418. "This procedure behaves like @code{member}, but does no type or error checking.\n"
  419. "Its use is recommended only in writing Guile internals,\n"
  420. "not for high-level Scheme programs.")
  421. #define FUNC_NAME s_scm_sloppy_member
  422. {
  423. scm_c_issue_deprecation_warning
  424. ("'sloppy-member' is deprecated. Use 'member' instead.");
  425. for(; scm_is_pair (lst); lst = SCM_CDR(lst))
  426. {
  427. if (! scm_is_false (scm_equal_p (SCM_CAR (lst), x)))
  428. return lst;
  429. }
  430. return lst;
  431. }
  432. #undef FUNC_NAME
  433. SCM_SYMBOL (scm_end_of_file_key, "end-of-file");
  434. SCM_DEFINE (scm_read_and_eval_x, "read-and-eval!", 0, 1, 0,
  435. (SCM port),
  436. "Read a form from @var{port} (standard input by default), and evaluate it\n"
  437. "(memoizing it in the process) in the top-level environment. If no data\n"
  438. "is left to be read from @var{port}, an @code{end-of-file} error is\n"
  439. "signalled.")
  440. #define FUNC_NAME s_scm_read_and_eval_x
  441. {
  442. SCM form;
  443. scm_c_issue_deprecation_warning
  444. ("'read-and-eval!' is deprecated. Use 'read' and 'eval' instead.");
  445. form = scm_read (port);
  446. if (SCM_EOF_OBJECT_P (form))
  447. scm_ithrow (scm_end_of_file_key, SCM_EOL, 1);
  448. return scm_eval_x (form, scm_current_module ());
  449. }
  450. #undef FUNC_NAME
  451. SCM
  452. scm_make_subr_opt (const char *name, int type, SCM (*fcn) (), int set)
  453. {
  454. scm_c_issue_deprecation_warning
  455. ("`scm_make_subr_opt' is deprecated. Use `scm_c_make_subr' or "
  456. "`scm_c_define_subr' instead.");
  457. if (set)
  458. return scm_c_define_subr (name, type, fcn);
  459. else
  460. return scm_c_make_subr (name, type, fcn);
  461. }
  462. SCM
  463. scm_make_subr (const char *name, int type, SCM (*fcn) ())
  464. {
  465. scm_c_issue_deprecation_warning
  466. ("`scm_make_subr' is deprecated. Use `scm_c_define_subr' instead.");
  467. return scm_c_define_subr (name, type, fcn);
  468. }
  469. SCM
  470. scm_make_subr_with_generic (const char *name, int type, SCM (*fcn) (), SCM *gf)
  471. {
  472. scm_c_issue_deprecation_warning
  473. ("`scm_make_subr_with_generic' is deprecated. Use "
  474. "`scm_c_define_subr_with_generic' instead.");
  475. return scm_c_define_subr_with_generic (name, type, fcn, gf);
  476. }
  477. /* Call thunk(closure) underneath a top-level error handler.
  478. * If an error occurs, pass the exitval through err_filter and return it.
  479. * If no error occurs, return the value of thunk.
  480. */
  481. #ifdef _UNICOS
  482. typedef int setjmp_type;
  483. #else
  484. typedef long setjmp_type;
  485. #endif
  486. struct cce_handler_data {
  487. SCM (*err_filter) ();
  488. void *closure;
  489. };
  490. static SCM
  491. invoke_err_filter (void *d, SCM tag, SCM args)
  492. {
  493. struct cce_handler_data *data = (struct cce_handler_data *)d;
  494. return data->err_filter (SCM_BOOL_F, data->closure);
  495. }
  496. SCM
  497. scm_call_catching_errors (SCM (*thunk)(), SCM (*err_filter)(), void *closure)
  498. {
  499. scm_c_issue_deprecation_warning
  500. ("'scm_call_catching_errors' is deprecated. "
  501. "Use 'scm_internal_catch' instead.");
  502. {
  503. struct cce_handler_data data;
  504. data.err_filter = err_filter;
  505. data.closure = closure;
  506. return scm_internal_catch (SCM_BOOL_T,
  507. (scm_t_catch_body)thunk, closure,
  508. (scm_t_catch_handler)invoke_err_filter, &data);
  509. }
  510. }
  511. long
  512. scm_make_smob_type_mfpe (char *name, size_t size,
  513. SCM (*mark) (SCM),
  514. size_t (*free) (SCM),
  515. int (*print) (SCM, SCM, scm_print_state *),
  516. SCM (*equalp) (SCM, SCM))
  517. {
  518. scm_c_issue_deprecation_warning
  519. ("'scm_make_smob_type_mfpe' is deprecated. "
  520. "Use 'scm_make_smob_type' plus 'scm_set_smob_*' instead.");
  521. {
  522. long answer = scm_make_smob_type (name, size);
  523. scm_set_smob_mfpe (answer, mark, free, print, equalp);
  524. return answer;
  525. }
  526. }
  527. void
  528. scm_set_smob_mfpe (long tc,
  529. SCM (*mark) (SCM),
  530. size_t (*free) (SCM),
  531. int (*print) (SCM, SCM, scm_print_state *),
  532. SCM (*equalp) (SCM, SCM))
  533. {
  534. scm_c_issue_deprecation_warning
  535. ("'scm_set_smob_mfpe' is deprecated. "
  536. "Use 'scm_set_smob_mark' instead, for example.");
  537. if (mark) scm_set_smob_mark (tc, mark);
  538. if (free) scm_set_smob_free (tc, free);
  539. if (print) scm_set_smob_print (tc, print);
  540. if (equalp) scm_set_smob_equalp (tc, equalp);
  541. }
  542. SCM
  543. scm_read_0str (char *expr)
  544. {
  545. scm_c_issue_deprecation_warning
  546. ("scm_read_0str is deprecated. Use scm_c_read_string instead.");
  547. return scm_c_read_string (expr);
  548. }
  549. SCM
  550. scm_eval_0str (const char *expr)
  551. {
  552. scm_c_issue_deprecation_warning
  553. ("scm_eval_0str is deprecated. Use scm_c_eval_string instead.");
  554. return scm_c_eval_string (expr);
  555. }
  556. SCM
  557. scm_strprint_obj (SCM obj)
  558. {
  559. scm_c_issue_deprecation_warning
  560. ("scm_strprint_obj is deprecated. Use scm_object_to_string instead.");
  561. return scm_object_to_string (obj, SCM_UNDEFINED);
  562. }
  563. char *
  564. scm_i_object_chars (SCM obj)
  565. {
  566. scm_c_issue_deprecation_warning
  567. ("SCM_CHARS is deprecated. See the manual for alternatives.");
  568. if (SCM_STRINGP (obj))
  569. return SCM_STRING_CHARS (obj);
  570. if (SCM_SYMBOLP (obj))
  571. return SCM_SYMBOL_CHARS (obj);
  572. abort ();
  573. }
  574. long
  575. scm_i_object_length (SCM obj)
  576. {
  577. scm_c_issue_deprecation_warning
  578. ("SCM_LENGTH is deprecated. "
  579. "Use scm_c_string_length instead, for example, or see the manual.");
  580. if (SCM_STRINGP (obj))
  581. return SCM_STRING_LENGTH (obj);
  582. if (SCM_SYMBOLP (obj))
  583. return SCM_SYMBOL_LENGTH (obj);
  584. if (SCM_VECTORP (obj))
  585. return SCM_VECTOR_LENGTH (obj);
  586. abort ();
  587. }
  588. SCM
  589. scm_sym2ovcell_soft (SCM sym, SCM obarray)
  590. {
  591. SCM lsym, z;
  592. size_t hash = scm_i_symbol_hash (sym) % SCM_VECTOR_LENGTH (obarray);
  593. scm_c_issue_deprecation_warning ("`scm_sym2ovcell_soft' is deprecated. "
  594. "Use hashtables instead.");
  595. SCM_CRITICAL_SECTION_START;
  596. for (lsym = SCM_VECTOR_REF (obarray, hash);
  597. SCM_NIMP (lsym);
  598. lsym = SCM_CDR (lsym))
  599. {
  600. z = SCM_CAR (lsym);
  601. if (scm_is_eq (SCM_CAR (z), sym))
  602. {
  603. SCM_CRITICAL_SECTION_END;
  604. return z;
  605. }
  606. }
  607. SCM_CRITICAL_SECTION_END;
  608. return SCM_BOOL_F;
  609. }
  610. SCM
  611. scm_sym2ovcell (SCM sym, SCM obarray)
  612. #define FUNC_NAME "scm_sym2ovcell"
  613. {
  614. SCM answer;
  615. scm_c_issue_deprecation_warning ("`scm_sym2ovcell' is deprecated. "
  616. "Use hashtables instead.");
  617. answer = scm_sym2ovcell_soft (sym, obarray);
  618. if (scm_is_true (answer))
  619. return answer;
  620. SCM_MISC_ERROR ("uninterned symbol: ~S", scm_list_1 (sym));
  621. return SCM_UNSPECIFIED; /* not reached */
  622. }
  623. #undef FUNC_NAME
  624. /* Intern a symbol whose name is the LEN characters at NAME in OBARRAY.
  625. OBARRAY should be a vector of lists, indexed by the name's hash
  626. value, modulo OBARRAY's length. Each list has the form
  627. ((SYMBOL . VALUE) ...), where SYMBOL is a symbol, and VALUE is the
  628. value associated with that symbol (in the current module? in the
  629. system module?)
  630. To "intern" a symbol means: if OBARRAY already contains a symbol by
  631. that name, return its (SYMBOL . VALUE) pair; otherwise, create a
  632. new symbol, add the pair (SYMBOL . SCM_UNDEFINED) to the
  633. appropriate list of the OBARRAY, and return the pair.
  634. If softness is non-zero, don't create a symbol if it isn't already
  635. in OBARRAY; instead, just return #f.
  636. If OBARRAY is SCM_BOOL_F, create a symbol listed in no obarray and
  637. return (SYMBOL . SCM_UNDEFINED). */
  638. SCM
  639. scm_intern_obarray_soft (const char *name,size_t len,SCM obarray,unsigned int softness)
  640. {
  641. SCM symbol = scm_from_locale_symboln (name, len);
  642. size_t raw_hash = scm_i_symbol_hash (symbol);
  643. size_t hash;
  644. SCM lsym;
  645. scm_c_issue_deprecation_warning ("`scm_intern_obarray_soft' is deprecated. "
  646. "Use hashtables instead.");
  647. if (scm_is_false (obarray))
  648. {
  649. if (softness)
  650. return SCM_BOOL_F;
  651. else
  652. return scm_cons (symbol, SCM_UNDEFINED);
  653. }
  654. hash = raw_hash % SCM_VECTOR_LENGTH (obarray);
  655. for (lsym = SCM_VECTOR_REF(obarray, hash);
  656. SCM_NIMP (lsym); lsym = SCM_CDR (lsym))
  657. {
  658. SCM a = SCM_CAR (lsym);
  659. SCM z = SCM_CAR (a);
  660. if (scm_is_eq (z, symbol))
  661. return a;
  662. }
  663. if (softness)
  664. {
  665. return SCM_BOOL_F;
  666. }
  667. else
  668. {
  669. SCM cell = scm_cons (symbol, SCM_UNDEFINED);
  670. SCM slot = SCM_VECTOR_REF (obarray, hash);
  671. SCM_VECTOR_SET (obarray, hash, scm_cons (cell, slot));
  672. return cell;
  673. }
  674. }
  675. SCM
  676. scm_intern_obarray (const char *name,size_t len,SCM obarray)
  677. {
  678. scm_c_issue_deprecation_warning ("`scm_intern_obarray' is deprecated. "
  679. "Use hashtables instead.");
  680. return scm_intern_obarray_soft (name, len, obarray, 0);
  681. }
  682. /* Lookup the value of the symbol named by the nul-terminated string
  683. NAME in the current module. */
  684. SCM
  685. scm_symbol_value0 (const char *name)
  686. {
  687. scm_c_issue_deprecation_warning ("`scm_symbol_value0' is deprecated. "
  688. "Use `scm_lookup' instead.");
  689. return scm_variable_ref (scm_c_lookup (name));
  690. }
  691. SCM_DEFINE (scm_string_to_obarray_symbol, "string->obarray-symbol", 2, 1, 0,
  692. (SCM o, SCM s, SCM softp),
  693. "Intern a new symbol in @var{obarray}, a symbol table, with name\n"
  694. "@var{string}.\n\n"
  695. "If @var{obarray} is @code{#f}, use the default system symbol table. If\n"
  696. "@var{obarray} is @code{#t}, the symbol should not be interned in any\n"
  697. "symbol table; merely return the pair (@var{symbol}\n"
  698. ". @var{#<undefined>}).\n\n"
  699. "The @var{soft?} argument determines whether new symbol table entries\n"
  700. "should be created when the specified symbol is not already present in\n"
  701. "@var{obarray}. If @var{soft?} is specified and is a true value, then\n"
  702. "new entries should not be added for symbols not already present in the\n"
  703. "table; instead, simply return @code{#f}.")
  704. #define FUNC_NAME s_scm_string_to_obarray_symbol
  705. {
  706. SCM vcell;
  707. SCM answer;
  708. int softness;
  709. SCM_VALIDATE_STRING (2, s);
  710. SCM_ASSERT (scm_is_bool (o) || SCM_VECTORP (o), o, SCM_ARG1, FUNC_NAME);
  711. scm_c_issue_deprecation_warning ("`string->obarray-symbol' is deprecated. "
  712. "Use hashtables instead.");
  713. softness = (!SCM_UNBNDP (softp) && scm_is_true(softp));
  714. /* iron out some screwy calling conventions */
  715. if (scm_is_false (o))
  716. {
  717. /* nothing interesting to do here. */
  718. return scm_string_to_symbol (s);
  719. }
  720. else if (scm_is_eq (o, SCM_BOOL_T))
  721. o = SCM_BOOL_F;
  722. vcell = scm_intern_obarray_soft (scm_i_string_chars (s),
  723. scm_i_string_length (s),
  724. o,
  725. softness);
  726. if (scm_is_false (vcell))
  727. return vcell;
  728. answer = SCM_CAR (vcell);
  729. return answer;
  730. }
  731. #undef FUNC_NAME
  732. SCM_DEFINE (scm_intern_symbol, "intern-symbol", 2, 0, 0,
  733. (SCM o, SCM s),
  734. "Add a new symbol to @var{obarray} with name @var{string}, bound to an\n"
  735. "unspecified initial value. The symbol table is not modified if a symbol\n"
  736. "with this name is already present.")
  737. #define FUNC_NAME s_scm_intern_symbol
  738. {
  739. size_t hval;
  740. SCM_VALIDATE_SYMBOL (2,s);
  741. if (scm_is_false (o))
  742. return SCM_UNSPECIFIED;
  743. scm_c_issue_deprecation_warning ("`intern-symbol' is deprecated. "
  744. "Use hashtables instead.");
  745. SCM_VALIDATE_VECTOR (1,o);
  746. hval = scm_i_symbol_hash (s) % SCM_VECTOR_LENGTH (o);
  747. /* If the symbol is already interned, simply return. */
  748. SCM_CRITICAL_SECTION_START;
  749. {
  750. SCM lsym;
  751. SCM sym;
  752. for (lsym = SCM_VECTOR_REF (o, hval);
  753. SCM_NIMP (lsym);
  754. lsym = SCM_CDR (lsym))
  755. {
  756. sym = SCM_CAR (lsym);
  757. if (scm_is_eq (SCM_CAR (sym), s))
  758. {
  759. SCM_CRITICAL_SECTION_END;
  760. return SCM_UNSPECIFIED;
  761. }
  762. }
  763. SCM_VECTOR_SET (o, hval,
  764. scm_acons (s, SCM_UNDEFINED,
  765. SCM_VECTOR_REF (o, hval)));
  766. }
  767. SCM_CRITICAL_SECTION_END;
  768. return SCM_UNSPECIFIED;
  769. }
  770. #undef FUNC_NAME
  771. SCM_DEFINE (scm_unintern_symbol, "unintern-symbol", 2, 0, 0,
  772. (SCM o, SCM s),
  773. "Remove the symbol with name @var{string} from @var{obarray}. This\n"
  774. "function returns @code{#t} if the symbol was present and @code{#f}\n"
  775. "otherwise.")
  776. #define FUNC_NAME s_scm_unintern_symbol
  777. {
  778. size_t hval;
  779. scm_c_issue_deprecation_warning ("`unintern-symbol' is deprecated. "
  780. "Use hashtables instead.");
  781. SCM_VALIDATE_SYMBOL (2,s);
  782. if (scm_is_false (o))
  783. return SCM_BOOL_F;
  784. SCM_VALIDATE_VECTOR (1,o);
  785. hval = scm_i_symbol_hash (s) % SCM_VECTOR_LENGTH (o);
  786. SCM_CRITICAL_SECTION_START;
  787. {
  788. SCM lsym_follow;
  789. SCM lsym;
  790. SCM sym;
  791. for (lsym = SCM_VECTOR_REF (o, hval), lsym_follow = SCM_BOOL_F;
  792. SCM_NIMP (lsym);
  793. lsym_follow = lsym, lsym = SCM_CDR (lsym))
  794. {
  795. sym = SCM_CAR (lsym);
  796. if (scm_is_eq (SCM_CAR (sym), s))
  797. {
  798. /* Found the symbol to unintern. */
  799. if (scm_is_false (lsym_follow))
  800. SCM_VECTOR_SET (o, hval, lsym);
  801. else
  802. SCM_SETCDR (lsym_follow, SCM_CDR(lsym));
  803. SCM_CRITICAL_SECTION_END;
  804. return SCM_BOOL_T;
  805. }
  806. }
  807. }
  808. SCM_CRITICAL_SECTION_END;
  809. return SCM_BOOL_F;
  810. }
  811. #undef FUNC_NAME
  812. SCM_DEFINE (scm_symbol_binding, "symbol-binding", 2, 0, 0,
  813. (SCM o, SCM s),
  814. "Look up in @var{obarray} the symbol whose name is @var{string}, and\n"
  815. "return the value to which it is bound. If @var{obarray} is @code{#f},\n"
  816. "use the global symbol table. If @var{string} is not interned in\n"
  817. "@var{obarray}, an error is signalled.")
  818. #define FUNC_NAME s_scm_symbol_binding
  819. {
  820. SCM vcell;
  821. scm_c_issue_deprecation_warning ("`symbol-binding' is deprecated. "
  822. "Use hashtables instead.");
  823. SCM_VALIDATE_SYMBOL (2,s);
  824. if (scm_is_false (o))
  825. return scm_variable_ref (scm_lookup (s));
  826. SCM_VALIDATE_VECTOR (1,o);
  827. vcell = scm_sym2ovcell (s, o);
  828. return SCM_CDR(vcell);
  829. }
  830. #undef FUNC_NAME
  831. #if 0
  832. SCM_DEFINE (scm_symbol_interned_p, "symbol-interned?", 2, 0, 0,
  833. (SCM o, SCM s),
  834. "Return @code{#t} if @var{obarray} contains a symbol with name\n"
  835. "@var{string}, and @code{#f} otherwise.")
  836. #define FUNC_NAME s_scm_symbol_interned_p
  837. {
  838. SCM vcell;
  839. scm_c_issue_deprecation_warning ("`symbol-interned?' is deprecated. "
  840. "Use hashtables instead.");
  841. SCM_VALIDATE_SYMBOL (2,s);
  842. if (scm_is_false (o))
  843. {
  844. SCM var = scm_sym2var (s, SCM_BOOL_F, SCM_BOOL_F);
  845. if (var != SCM_BOOL_F)
  846. return SCM_BOOL_T;
  847. return SCM_BOOL_F;
  848. }
  849. SCM_VALIDATE_VECTOR (1,o);
  850. vcell = scm_sym2ovcell_soft (s, o);
  851. return (SCM_NIMP(vcell)
  852. ? SCM_BOOL_T
  853. : SCM_BOOL_F);
  854. }
  855. #undef FUNC_NAME
  856. #endif
  857. SCM_DEFINE (scm_symbol_bound_p, "symbol-bound?", 2, 0, 0,
  858. (SCM o, SCM s),
  859. "Return @code{#t} if @var{obarray} contains a symbol with name\n"
  860. "@var{string} bound to a defined value. This differs from\n"
  861. "@var{symbol-interned?} in that the mere mention of a symbol\n"
  862. "usually causes it to be interned; @code{symbol-bound?}\n"
  863. "determines whether a symbol has been given any meaningful\n"
  864. "value.")
  865. #define FUNC_NAME s_scm_symbol_bound_p
  866. {
  867. SCM vcell;
  868. scm_c_issue_deprecation_warning ("`symbol-bound?' is deprecated. "
  869. "Use hashtables instead.");
  870. SCM_VALIDATE_SYMBOL (2,s);
  871. if (scm_is_false (o))
  872. {
  873. SCM var = scm_sym2var (s, SCM_BOOL_F, SCM_BOOL_F);
  874. if (SCM_VARIABLEP(var) && !SCM_UNBNDP(SCM_VARIABLE_REF(var)))
  875. return SCM_BOOL_T;
  876. return SCM_BOOL_F;
  877. }
  878. SCM_VALIDATE_VECTOR (1,o);
  879. vcell = scm_sym2ovcell_soft (s, o);
  880. return scm_from_bool (SCM_NIMP (vcell) && !SCM_UNBNDP (SCM_CDR (vcell)));
  881. }
  882. #undef FUNC_NAME
  883. SCM_DEFINE (scm_symbol_set_x, "symbol-set!", 3, 0, 0,
  884. (SCM o, SCM s, SCM v),
  885. "Find the symbol in @var{obarray} whose name is @var{string}, and rebind\n"
  886. "it to @var{value}. An error is signalled if @var{string} is not present\n"
  887. "in @var{obarray}.")
  888. #define FUNC_NAME s_scm_symbol_set_x
  889. {
  890. SCM vcell;
  891. scm_c_issue_deprecation_warning ("`symbol-set!' is deprecated. "
  892. "Use the module system instead.");
  893. SCM_VALIDATE_SYMBOL (2,s);
  894. if (scm_is_false (o))
  895. {
  896. scm_define (s, v);
  897. return SCM_UNSPECIFIED;
  898. }
  899. SCM_VALIDATE_VECTOR (1,o);
  900. vcell = scm_sym2ovcell (s, o);
  901. SCM_SETCDR (vcell, v);
  902. return SCM_UNSPECIFIED;
  903. }
  904. #undef FUNC_NAME
  905. #define MAX_PREFIX_LENGTH 30
  906. static int gentemp_counter;
  907. SCM_DEFINE (scm_gentemp, "gentemp", 0, 2, 0,
  908. (SCM prefix, SCM obarray),
  909. "Create a new symbol with a name unique in an obarray.\n"
  910. "The name is constructed from an optional string @var{prefix}\n"
  911. "and a counter value. The default prefix is @code{t}. The\n"
  912. "@var{obarray} is specified as a second optional argument.\n"
  913. "Default is the system obarray where all normal symbols are\n"
  914. "interned. The counter is increased by 1 at each\n"
  915. "call. There is no provision for resetting the counter.")
  916. #define FUNC_NAME s_scm_gentemp
  917. {
  918. char buf[MAX_PREFIX_LENGTH + SCM_INTBUFLEN];
  919. char *name = buf;
  920. int len, n_digits;
  921. scm_c_issue_deprecation_warning ("`gentemp' is deprecated. "
  922. "Use `gensym' instead.");
  923. if (SCM_UNBNDP (prefix))
  924. {
  925. name[0] = 't';
  926. len = 1;
  927. }
  928. else
  929. {
  930. SCM_VALIDATE_STRING (1, prefix);
  931. len = scm_i_string_length (prefix);
  932. if (len > MAX_PREFIX_LENGTH)
  933. name = SCM_MUST_MALLOC (MAX_PREFIX_LENGTH + SCM_INTBUFLEN);
  934. strncpy (name, scm_i_string_chars (prefix), len);
  935. }
  936. if (SCM_UNBNDP (obarray))
  937. return scm_gensym (prefix);
  938. else
  939. SCM_ASSERT ((scm_is_vector (obarray) || SCM_I_WVECTP (obarray)),
  940. obarray,
  941. SCM_ARG2,
  942. FUNC_NAME);
  943. do
  944. n_digits = scm_iint2str (gentemp_counter++, 10, &name[len]);
  945. while (scm_is_true (scm_intern_obarray_soft (name,
  946. len + n_digits,
  947. obarray,
  948. 1)));
  949. {
  950. SCM vcell = scm_intern_obarray_soft (name,
  951. len + n_digits,
  952. obarray,
  953. 0);
  954. if (name != buf)
  955. scm_must_free (name);
  956. return SCM_CAR (vcell);
  957. }
  958. }
  959. #undef FUNC_NAME
  960. SCM
  961. scm_i_makinum (scm_t_signed_bits val)
  962. {
  963. scm_c_issue_deprecation_warning
  964. ("SCM_MAKINUM is deprecated. Use scm_from_int or similar instead.");
  965. return SCM_I_MAKINUM (val);
  966. }
  967. int
  968. scm_i_inump (SCM obj)
  969. {
  970. scm_c_issue_deprecation_warning
  971. ("SCM_INUMP is deprecated. Use scm_is_integer or similar instead.");
  972. return SCM_I_INUMP (obj);
  973. }
  974. scm_t_signed_bits
  975. scm_i_inum (SCM obj)
  976. {
  977. scm_c_issue_deprecation_warning
  978. ("SCM_INUM is deprecated. Use scm_to_int or similar instead.");
  979. return scm_to_intmax (obj);
  980. }
  981. char *
  982. scm_c_string2str (SCM obj, char *str, size_t *lenp)
  983. {
  984. scm_c_issue_deprecation_warning
  985. ("scm_c_string2str is deprecated. Use scm_to_locale_stringbuf or similar instead.");
  986. if (str == NULL)
  987. {
  988. char *result = scm_to_locale_string (obj);
  989. if (lenp)
  990. *lenp = scm_i_string_length (obj);
  991. return result;
  992. }
  993. else
  994. {
  995. /* Pray that STR is large enough.
  996. */
  997. size_t len = scm_to_locale_stringbuf (obj, str, SCM_I_SIZE_MAX);
  998. str[len] = '\0';
  999. if (lenp)
  1000. *lenp = len;
  1001. return str;
  1002. }
  1003. }
  1004. char *
  1005. scm_c_substring2str (SCM obj, char *str, size_t start, size_t len)
  1006. {
  1007. scm_c_issue_deprecation_warning
  1008. ("scm_c_substring2str is deprecated. Use scm_substring plus scm_to_locale_stringbuf instead.");
  1009. if (start)
  1010. obj = scm_substring (obj, scm_from_size_t (start), SCM_UNDEFINED);
  1011. scm_to_locale_stringbuf (obj, str, len);
  1012. return str;
  1013. }
  1014. /* Converts the given Scheme symbol OBJ into a C string, containing a copy
  1015. of OBJ's content with a trailing null byte. If LENP is non-NULL, set
  1016. *LENP to the string's length.
  1017. When STR is non-NULL it receives the copy and is returned by the function,
  1018. otherwise new memory is allocated and the caller is responsible for
  1019. freeing it via free(). If out of memory, NULL is returned.
  1020. Note that Scheme symbols may contain arbitrary data, including null
  1021. characters. This means that null termination is not a reliable way to
  1022. determine the length of the returned value. However, the function always
  1023. copies the complete contents of OBJ, and sets *LENP to the length of the
  1024. scheme symbol (if LENP is non-null). */
  1025. char *
  1026. scm_c_symbol2str (SCM obj, char *str, size_t *lenp)
  1027. {
  1028. return scm_c_string2str (scm_symbol_to_string (obj), str, lenp);
  1029. }
  1030. double
  1031. scm_truncate (double x)
  1032. {
  1033. scm_c_issue_deprecation_warning
  1034. ("scm_truncate is deprecated. Use scm_c_truncate instead.");
  1035. return scm_c_truncate (x);
  1036. }
  1037. double
  1038. scm_round (double x)
  1039. {
  1040. scm_c_issue_deprecation_warning
  1041. ("scm_round is deprecated. Use scm_c_round instead.");
  1042. return scm_c_round (x);
  1043. }
  1044. char *
  1045. scm_i_deprecated_symbol_chars (SCM sym)
  1046. {
  1047. scm_c_issue_deprecation_warning
  1048. ("SCM_SYMBOL_CHARS is deprecated. Use scm_symbol_to_string.");
  1049. return (char *)scm_i_symbol_chars (sym);
  1050. }
  1051. size_t
  1052. scm_i_deprecated_symbol_length (SCM sym)
  1053. {
  1054. scm_c_issue_deprecation_warning
  1055. ("SCM_SYMBOL_LENGTH is deprecated. Use scm_symbol_to_string.");
  1056. return scm_i_symbol_length (sym);
  1057. }
  1058. int
  1059. scm_i_keywordp (SCM obj)
  1060. {
  1061. scm_c_issue_deprecation_warning
  1062. ("SCM_KEYWORDP is deprecated. Use scm_is_keyword instead.");
  1063. return scm_is_keyword (obj);
  1064. }
  1065. SCM
  1066. scm_i_keywordsym (SCM keyword)
  1067. {
  1068. scm_c_issue_deprecation_warning
  1069. ("SCM_KEYWORDSYM is deprecated. See scm_keyword_to_symbol instead.");
  1070. return scm_keyword_dash_symbol (keyword);
  1071. }
  1072. int
  1073. scm_i_vectorp (SCM x)
  1074. {
  1075. scm_c_issue_deprecation_warning
  1076. ("SCM_VECTORP is deprecated. Use scm_is_vector instead.");
  1077. return SCM_I_IS_VECTOR (x);
  1078. }
  1079. unsigned long
  1080. scm_i_vector_length (SCM x)
  1081. {
  1082. scm_c_issue_deprecation_warning
  1083. ("SCM_VECTOR_LENGTH is deprecated. Use scm_c_vector_length instead.");
  1084. return SCM_I_VECTOR_LENGTH (x);
  1085. }
  1086. const SCM *
  1087. scm_i_velts (SCM x)
  1088. {
  1089. scm_c_issue_deprecation_warning
  1090. ("SCM_VELTS is deprecated. Use scm_vector_elements instead.");
  1091. return SCM_I_VECTOR_ELTS (x);
  1092. }
  1093. SCM *
  1094. scm_i_writable_velts (SCM x)
  1095. {
  1096. scm_c_issue_deprecation_warning
  1097. ("SCM_WRITABLE_VELTS is deprecated. "
  1098. "Use scm_vector_writable_elements instead.");
  1099. return SCM_I_VECTOR_WELTS (x);
  1100. }
  1101. SCM
  1102. scm_i_vector_ref (SCM x, size_t idx)
  1103. {
  1104. scm_c_issue_deprecation_warning
  1105. ("SCM_VECTOR_REF is deprecated. "
  1106. "Use scm_c_vector_ref or scm_vector_elements instead.");
  1107. return scm_c_vector_ref (x, idx);
  1108. }
  1109. void
  1110. scm_i_vector_set (SCM x, size_t idx, SCM val)
  1111. {
  1112. scm_c_issue_deprecation_warning
  1113. ("SCM_VECTOR_SET is deprecated. "
  1114. "Use scm_c_vector_set_x or scm_vector_writable_elements instead.");
  1115. scm_c_vector_set_x (x, idx, val);
  1116. }
  1117. SCM
  1118. scm_vector_equal_p (SCM x, SCM y)
  1119. {
  1120. scm_c_issue_deprecation_warning
  1121. ("scm_vector_euqal_p is deprecated. "
  1122. "Use scm_equal_p instead.");
  1123. return scm_equal_p (x, y);
  1124. }
  1125. int
  1126. scm_i_arrayp (SCM a)
  1127. {
  1128. scm_c_issue_deprecation_warning
  1129. ("SCM_ARRAYP is deprecated. Use scm_is_array instead.");
  1130. return SCM_I_ARRAYP(a) || SCM_I_ENCLOSED_ARRAYP(a);
  1131. }
  1132. size_t
  1133. scm_i_array_ndim (SCM a)
  1134. {
  1135. scm_c_issue_deprecation_warning
  1136. ("SCM_ARRAY_NDIM is deprecated. "
  1137. "Use scm_c_array_rank or scm_array_handle_rank instead.");
  1138. return scm_c_array_rank (a);
  1139. }
  1140. int
  1141. scm_i_array_contp (SCM a)
  1142. {
  1143. scm_c_issue_deprecation_warning
  1144. ("SCM_ARRAY_CONTP is deprecated. Do not use it.");
  1145. return SCM_I_ARRAY_CONTP (a);
  1146. }
  1147. scm_t_array *
  1148. scm_i_array_mem (SCM a)
  1149. {
  1150. scm_c_issue_deprecation_warning
  1151. ("SCM_ARRAY_MEM is deprecated. Do not use it.");
  1152. return (scm_t_array *)SCM_I_ARRAY_MEM (a);
  1153. }
  1154. SCM
  1155. scm_i_array_v (SCM a)
  1156. {
  1157. /* We could use scm_shared_array_root here, but it is better to move
  1158. them away from expecting vectors as the basic storage for arrays.
  1159. */
  1160. scm_c_issue_deprecation_warning
  1161. ("SCM_ARRAY_V is deprecated. Do not use it.");
  1162. return SCM_I_ARRAY_V (a);
  1163. }
  1164. size_t
  1165. scm_i_array_base (SCM a)
  1166. {
  1167. scm_c_issue_deprecation_warning
  1168. ("SCM_ARRAY_BASE is deprecated. Do not use it.");
  1169. return SCM_I_ARRAY_BASE (a);
  1170. }
  1171. scm_t_array_dim *
  1172. scm_i_array_dims (SCM a)
  1173. {
  1174. scm_c_issue_deprecation_warning
  1175. ("SCM_ARRAY_DIMS is deprecated. Use scm_array_handle_dims instead.");
  1176. return SCM_I_ARRAY_DIMS (a);
  1177. }
  1178. SCM
  1179. scm_i_cur_inp (void)
  1180. {
  1181. scm_c_issue_deprecation_warning
  1182. ("scm_cur_inp is deprecated. Use scm_current_input_port instead.");
  1183. return scm_current_input_port ();
  1184. }
  1185. SCM
  1186. scm_i_cur_outp (void)
  1187. {
  1188. scm_c_issue_deprecation_warning
  1189. ("scm_cur_outp is deprecated. Use scm_current_output_port instead.");
  1190. return scm_current_output_port ();
  1191. }
  1192. SCM
  1193. scm_i_cur_errp (void)
  1194. {
  1195. scm_c_issue_deprecation_warning
  1196. ("scm_cur_errp is deprecated. Use scm_current_error_port instead.");
  1197. return scm_current_error_port ();
  1198. }
  1199. SCM
  1200. scm_i_cur_loadp (void)
  1201. {
  1202. scm_c_issue_deprecation_warning
  1203. ("scm_cur_loadp is deprecated. Use scm_current_load_port instead.");
  1204. return scm_current_load_port ();
  1205. }
  1206. SCM
  1207. scm_i_progargs (void)
  1208. {
  1209. scm_c_issue_deprecation_warning
  1210. ("scm_progargs is deprecated. Use scm_program_arguments instead.");
  1211. return scm_program_arguments ();
  1212. }
  1213. SCM
  1214. scm_i_deprecated_dynwinds (void)
  1215. {
  1216. scm_c_issue_deprecation_warning
  1217. ("scm_dynwinds is deprecated. Do not use it.");
  1218. return scm_i_dynwinds ();
  1219. }
  1220. scm_t_debug_frame *
  1221. scm_i_deprecated_last_debug_frame (void)
  1222. {
  1223. scm_c_issue_deprecation_warning
  1224. ("scm_last_debug_frame is deprecated. Do not use it.");
  1225. return scm_i_last_debug_frame ();
  1226. }
  1227. SCM_STACKITEM *
  1228. scm_i_stack_base (void)
  1229. {
  1230. scm_c_issue_deprecation_warning
  1231. ("scm_stack_base is deprecated. Do not use it.");
  1232. return SCM_I_CURRENT_THREAD->base;
  1233. }
  1234. int
  1235. scm_i_fluidp (SCM x)
  1236. {
  1237. scm_c_issue_deprecation_warning
  1238. ("SCM_FLUIDP is deprecated. Use scm_is_fluid instead.");
  1239. return scm_is_fluid (x);
  1240. }
  1241. void
  1242. scm_i_defer_ints_etc ()
  1243. {
  1244. scm_c_issue_deprecation_warning
  1245. ("SCM_DEFER_INTS etc are deprecated. "
  1246. "Use a mutex instead if appropriate.");
  1247. }
  1248. SCM
  1249. scm_guard (SCM guardian, SCM obj, int throw_p)
  1250. {
  1251. scm_c_issue_deprecation_warning
  1252. ("scm_guard is deprecated. Use scm_call_1 instead.");
  1253. return scm_call_1 (guardian, obj);
  1254. }
  1255. SCM
  1256. scm_get_one_zombie (SCM guardian)
  1257. {
  1258. scm_c_issue_deprecation_warning
  1259. ("scm_guard is deprecated. Use scm_call_0 instead.");
  1260. return scm_call_0 (guardian);
  1261. }
  1262. SCM_DEFINE (scm_guardian_destroyed_p, "guardian-destroyed?", 1, 0, 0,
  1263. (SCM guardian),
  1264. "Return @code{#t} if @var{guardian} has been destroyed, otherwise @code{#f}.")
  1265. #define FUNC_NAME s_scm_guardian_destroyed_p
  1266. {
  1267. scm_c_issue_deprecation_warning
  1268. ("'guardian-destroyed?' is deprecated.");
  1269. return SCM_BOOL_F;
  1270. }
  1271. #undef FUNC_NAME
  1272. SCM_DEFINE (scm_guardian_greedy_p, "guardian-greedy?", 1, 0, 0,
  1273. (SCM guardian),
  1274. "Return @code{#t} if @var{guardian} is a greedy guardian, otherwise @code{#f}.")
  1275. #define FUNC_NAME s_scm_guardian_greedy_p
  1276. {
  1277. scm_c_issue_deprecation_warning
  1278. ("'guardian-greedy?' is deprecated.");
  1279. return SCM_BOOL_F;
  1280. }
  1281. #undef FUNC_NAME
  1282. SCM_DEFINE (scm_destroy_guardian_x, "destroy-guardian!", 1, 0, 0,
  1283. (SCM guardian),
  1284. "Destroys @var{guardian}, by making it impossible to put any more\n"
  1285. "objects in it or get any objects from it. It also unguards any\n"
  1286. "objects guarded by @var{guardian}.")
  1287. #define FUNC_NAME s_scm_destroy_guardian_x
  1288. {
  1289. scm_c_issue_deprecation_warning
  1290. ("'destroy-guardian!' is deprecated and ineffective.");
  1291. return SCM_UNSPECIFIED;
  1292. }
  1293. #undef FUNC_NAME
  1294. void
  1295. scm_i_init_deprecated ()
  1296. {
  1297. #include "libguile/deprecated.x"
  1298. }
  1299. #endif