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