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