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