expt implemented in C, handles complex numbers
[bpt/guile.git] / libguile / deprecated.c
CommitLineData
19e2247d
MV
1/* This file contains definitions for deprecated features. When you
2 deprecate something, move it here when that is feasible.
3*/
4
760fb97d 5/* Copyright (C) 2003, 2004, 2006, 2008, 2009 Free Software Foundation, Inc.
19e2247d 6 *
73be1d9e 7 * This library is free software; you can redistribute it and/or
53befeb7
NJ
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.
19e2247d 11 *
53befeb7
NJ
12 * This library is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
73be1d9e
MV
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
19e2247d 16 *
73be1d9e
MV
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
53befeb7
NJ
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
20 * 02110-1301 USA
73be1d9e 21 */
19e2247d 22
dbb605f5
LC
23#ifdef HAVE_CONFIG_H
24# include <config.h>
25#endif
26
0eb934f1
LC
27#define SCM_BUILDING_DEPRECATED_CODE
28
19e2247d 29#include "libguile/_scm.h"
4e047c3e 30#include "libguile/async.h"
19e2247d 31#include "libguile/deprecated.h"
db74ed03 32#include "libguile/discouraged.h"
55d30fac 33#include "libguile/deprecation.h"
19e2247d
MV
34#include "libguile/snarf.h"
35#include "libguile/validate.h"
36#include "libguile/strings.h"
c44ca4fe 37#include "libguile/srfi-13.h"
a0454d72 38#include "libguile/modules.h"
1030b450 39#include "libguile/generalized-arrays.h"
a0454d72
MV
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"
965445d4
MV
49#include "libguile/eq.h"
50#include "libguile/read.h"
4abecea8
MV
51#include "libguile/strports.h"
52#include "libguile/smob.h"
cc5c1b66 53#include "libguile/alist.h"
db74ed03 54#include "libguile/keywords.h"
3452e666 55#include "libguile/socket.h"
9de87eea 56#include "libguile/feature.h"
19e2247d 57
55d30fac
MV
58#include <stdio.h>
59#include <string.h>
60
3452e666
LC
61#include <arpa/inet.h>
62
19e2247d
MV
63#if (SCM_ENABLE_DEPRECATED == 1)
64
7e6e6b37
DH
65/* From print.c: Internal symbol names of isyms. Deprecated in guile 1.7.0 on
66 * 2004-04-22. */
67char *scm_isymnames[] =
68{
69 "#@<deprecated>"
70};
71
72
19e2247d
MV
73SCM_REGISTER_PROC(s_substring_move_left_x, "substring-move-left!", 5, 0, 0, scm_substring_move_x);
74
75SCM_REGISTER_PROC(s_substring_move_right_x, "substring-move-right!", 5, 0, 0, scm_substring_move_x);
76
55d30fac
MV
77SCM
78scm_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
132struct moddata {
133 struct moddata *link;
134 char *module_name;
135 void *init_func;
136};
137
138static struct moddata *registered_mods = NULL;
139
140void
141scm_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
172SCM_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)
3ee86942 186 res = scm_cons (scm_cons (scm_from_locale_string (md->module_name),
c71b0706 187 scm_from_ulong ((unsigned long) md->init_func)),
55d30fac
MV
188 res);
189 return res;
190}
191#undef FUNC_NAME
192
193SCM_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
9de87eea 204 SCM_CRITICAL_SECTION_START;
55d30fac
MV
205
206 for (md1 = registered_mods; md1; md1 = md2)
207 {
208 md2 = md1->link;
209 free (md1);
210 }
211 registered_mods = NULL;
212
9de87eea 213 SCM_CRITICAL_SECTION_END;
55d30fac
MV
214 return SCM_UNSPECIFIED;
215}
216#undef FUNC_NAME
217
a0454d72
MV
218void
219scm_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
225SCM
226scm_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
233SCM
234scm_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
241SCM_SYMBOL (scm_sym_app, "app");
242SCM_SYMBOL (scm_sym_modules, "modules");
243static SCM module_prefix = SCM_BOOL_F;
244static SCM make_modules_in_var;
245static SCM beautify_user_module_x_var;
246static SCM try_module_autoload_var;
247
248static void
249init_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
a0454d72
MV
263static SCM
264scm_module_full_name (SCM name)
265{
266 init_module_stuff ();
bc36d050 267 if (scm_is_eq (SCM_CAR (name), scm_sym_app))
a0454d72
MV
268 return name;
269 else
270 return scm_append (scm_list_2 (module_prefix, name));
271}
272
273SCM
274scm_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
285SCM
286scm_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
296SCM
297scm_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
308static void
309maybe_close_port (void *data, SCM port)
310{
6eadcdab 311 SCM except_set = (SCM) data;
a0454d72 312
6eadcdab 313 while (!scm_is_null (except_set))
a0454d72 314 {
6eadcdab 315 SCM p = SCM_COERCE_OUTPORT (SCM_CAR (except_set));
bc36d050 316 if (scm_is_eq (p, port))
a0454d72 317 return;
6eadcdab 318 except_set = SCM_CDR (except_set);
a0454d72
MV
319 }
320
321 scm_close_port (port);
322}
323
324SCM_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
d2e53ed6 337 for (p = ports; !scm_is_null (p); p = SCM_CDR (p))
a0454d72
MV
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
55d30fac 345
965445d4
MV
346SCM_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
359SCM_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
371SCM
372scm_makstr (size_t len, int dummy)
373{
374 scm_c_issue_deprecation_warning
3ee86942
MV
375 ("'scm_makstr' is deprecated. Use 'scm_c_make_string' instead.");
376 return scm_c_make_string (len, SCM_UNDEFINED);
965445d4
MV
377}
378
379SCM
380scm_makfromstr (const char *src, size_t len, int dummy SCM_UNUSED)
381{
382 scm_c_issue_deprecation_warning ("`scm_makfromstr' is deprecated. "
3ee86942 383 "Use `scm_from_locale_stringn' instead.");
965445d4 384
3ee86942 385 return scm_from_locale_stringn (src, len);
965445d4
MV
386}
387
388SCM
389scm_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
397SCM
398scm_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
406SCM
407scm_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
418SCM
419scm_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 {
7888309b 425 SCM hook = scm_make_hook (scm_from_int (n_args));
965445d4
MV
426 scm_c_define (name, hook);
427 return scm_permanent_object (hook);
428 }
429}
430
431SCM_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
d2e53ed6 441 for(; scm_is_pair (lst); lst = SCM_CDR(lst))
965445d4 442 {
bc36d050 443 if (scm_is_eq (SCM_CAR (lst), x))
965445d4
MV
444 return lst;
445 }
446 return lst;
447}
448#undef FUNC_NAME
449
450
451SCM_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
d2e53ed6 461 for(; scm_is_pair (lst); lst = SCM_CDR(lst))
965445d4 462 {
7888309b 463 if (! scm_is_false (scm_eqv_p (SCM_CAR (lst), x)))
965445d4
MV
464 return lst;
465 }
466 return lst;
467}
468#undef FUNC_NAME
469
470
471SCM_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
d2e53ed6 481 for(; scm_is_pair (lst); lst = SCM_CDR(lst))
965445d4 482 {
7888309b 483 if (! scm_is_false (scm_equal_p (SCM_CAR (lst), x)))
965445d4
MV
484 return lst;
485 }
486 return lst;
487}
488#undef FUNC_NAME
489
490SCM_SYMBOL (scm_end_of_file_key, "end-of-file");
491
492SCM_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{
f8ba2197
DH
500 SCM form;
501
965445d4
MV
502 scm_c_issue_deprecation_warning
503 ("'read-and-eval!' is deprecated. Use 'read' and 'eval' instead.");
504
f8ba2197 505 form = scm_read (port);
965445d4
MV
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
4abecea8
MV
512SCM
513scm_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
525SCM
526scm_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
534SCM
535scm_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
550typedef int setjmp_type;
551#else
552typedef long setjmp_type;
553#endif
554
555struct cce_handler_data {
556 SCM (*err_filter) ();
557 void *closure;
558};
559
560static SCM
561invoke_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
567SCM
568scm_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
584long
585scm_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
602void
603scm_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
3051344b
LC
619size_t
620scm_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
4abecea8
MV
634SCM
635scm_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
643SCM
644scm_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
652SCM
653scm_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
a725fa95
MV
660char *
661scm_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
672long
673scm_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
cc5c1b66
MV
687SCM
688scm_sym2ovcell_soft (SCM sym, SCM obarray)
689{
690 SCM lsym, z;
3ee86942 691 size_t hash = scm_i_symbol_hash (sym) % SCM_VECTOR_LENGTH (obarray);
cc5c1b66
MV
692
693 scm_c_issue_deprecation_warning ("`scm_sym2ovcell_soft' is deprecated. "
694 "Use hashtables instead.");
695
9de87eea 696 SCM_CRITICAL_SECTION_START;
cc5c1b66
MV
697 for (lsym = SCM_VECTOR_REF (obarray, hash);
698 SCM_NIMP (lsym);
699 lsym = SCM_CDR (lsym))
700 {
701 z = SCM_CAR (lsym);
bc36d050 702 if (scm_is_eq (SCM_CAR (z), sym))
cc5c1b66 703 {
9de87eea 704 SCM_CRITICAL_SECTION_END;
cc5c1b66
MV
705 return z;
706 }
707 }
9de87eea 708 SCM_CRITICAL_SECTION_END;
cc5c1b66
MV
709 return SCM_BOOL_F;
710}
711
712
713SCM
714scm_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);
7888309b 723 if (scm_is_true (answer))
cc5c1b66
MV
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
7f594642
MG
751static SCM
752intern_obarray_soft (SCM symbol, SCM obarray, unsigned int softness)
cc5c1b66 753{
3ee86942 754 size_t raw_hash = scm_i_symbol_hash (symbol);
cc5c1b66
MV
755 size_t hash;
756 SCM lsym;
757
7888309b 758 if (scm_is_false (obarray))
cc5c1b66
MV
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);
bc36d050 773 if (scm_is_eq (z, symbol))
cc5c1b66
MV
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
7f594642
MG
793SCM
794scm_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
cc5c1b66
MV
805SCM
806scm_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. */
816SCM
817scm_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
825SCM_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);
7888309b 845 SCM_ASSERT (scm_is_bool (o) || SCM_VECTORP (o), o, SCM_ARG1, FUNC_NAME);
cc5c1b66
MV
846
847 scm_c_issue_deprecation_warning ("`string->obarray-symbol' is deprecated. "
848 "Use hashtables instead.");
849
7888309b 850 softness = (!SCM_UNBNDP (softp) && scm_is_true(softp));
cc5c1b66 851 /* iron out some screwy calling conventions */
7888309b 852 if (scm_is_false (o))
cc5c1b66
MV
853 {
854 /* nothing interesting to do here. */
855 return scm_string_to_symbol (s);
856 }
bc36d050 857 else if (scm_is_eq (o, SCM_BOOL_T))
cc5c1b66
MV
858 o = SCM_BOOL_F;
859
7f594642 860 vcell = intern_obarray_soft (scm_string_to_symbol (s), o, softness);
7888309b 861 if (scm_is_false (vcell))
cc5c1b66
MV
862 return vcell;
863 answer = SCM_CAR (vcell);
864 return answer;
865}
866#undef FUNC_NAME
867
868SCM_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);
7888309b 877 if (scm_is_false (o))
cc5c1b66
MV
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);
3ee86942 884 hval = scm_i_symbol_hash (s) % SCM_VECTOR_LENGTH (o);
cc5c1b66 885 /* If the symbol is already interned, simply return. */
9de87eea 886 SCM_CRITICAL_SECTION_START;
cc5c1b66
MV
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);
bc36d050 895 if (scm_is_eq (SCM_CAR (sym), s))
cc5c1b66 896 {
9de87eea 897 SCM_CRITICAL_SECTION_END;
cc5c1b66
MV
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 }
9de87eea 905 SCM_CRITICAL_SECTION_END;
cc5c1b66
MV
906 return SCM_UNSPECIFIED;
907}
908#undef FUNC_NAME
909
910SCM_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);
7888309b 923 if (scm_is_false (o))
cc5c1b66
MV
924 return SCM_BOOL_F;
925 SCM_VALIDATE_VECTOR (1,o);
3ee86942 926 hval = scm_i_symbol_hash (s) % SCM_VECTOR_LENGTH (o);
9de87eea 927 SCM_CRITICAL_SECTION_START;
cc5c1b66
MV
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);
bc36d050 937 if (scm_is_eq (SCM_CAR (sym), s))
cc5c1b66
MV
938 {
939 /* Found the symbol to unintern. */
7888309b 940 if (scm_is_false (lsym_follow))
cc5c1b66
MV
941 SCM_VECTOR_SET (o, hval, lsym);
942 else
943 SCM_SETCDR (lsym_follow, SCM_CDR(lsym));
9de87eea 944 SCM_CRITICAL_SECTION_END;
cc5c1b66
MV
945 return SCM_BOOL_T;
946 }
947 }
948 }
9de87eea 949 SCM_CRITICAL_SECTION_END;
cc5c1b66
MV
950 return SCM_BOOL_F;
951}
952#undef FUNC_NAME
953
954SCM_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);
7888309b 968 if (scm_is_false (o))
cc5c1b66
MV
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
977SCM_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);
7888309b 989 if (scm_is_false (o))
cc5c1b66
MV
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
1005SCM_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);
7888309b 1021 if (scm_is_false (o))
cc5c1b66
MV
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);
7888309b 1030 return scm_from_bool (SCM_NIMP (vcell) && !SCM_UNBNDP (SCM_CDR (vcell)));
cc5c1b66
MV
1031}
1032#undef FUNC_NAME
1033
1034
1035SCM_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);
7888309b 1048 if (scm_is_false (o))
cc5c1b66
MV
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
1062static int gentemp_counter;
1063
1064SCM_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;
806f1ded
MG
1077 int n_digits;
1078 size_t len;
cc5c1b66
MV
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);
3ee86942 1091 len = scm_i_string_length (prefix);
806f1ded 1092 name = scm_to_locale_stringn (prefix, &len);
7f594642 1093 name = scm_realloc (name, len + SCM_INTBUFLEN);
cc5c1b66
MV
1094 }
1095
1096 if (SCM_UNBNDP (obarray))
1097 return scm_gensym (prefix);
1098 else
4057a3e0 1099 SCM_ASSERT ((scm_is_vector (obarray) || SCM_I_WVECTP (obarray)),
cc5c1b66
MV
1100 obarray,
1101 SCM_ARG2,
1102 FUNC_NAME);
1103 do
1104 n_digits = scm_iint2str (gentemp_counter++, 10, &name[len]);
7888309b 1105 while (scm_is_true (scm_intern_obarray_soft (name,
cc5c1b66
MV
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)
7f594642 1115 free (name);
cc5c1b66
MV
1116 return SCM_CAR (vcell);
1117 }
1118}
1119#undef FUNC_NAME
1120
7888309b 1121SCM
fe78c51a 1122scm_i_makinum (scm_t_signed_bits val)
7888309b
MV
1123{
1124 scm_c_issue_deprecation_warning
1125 ("SCM_MAKINUM is deprecated. Use scm_from_int or similar instead.");
3aa13a05
MV
1126 return SCM_I_MAKINUM (val);
1127}
1128
1129int
fe78c51a 1130scm_i_inump (SCM obj)
3aa13a05
MV
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
1137scm_t_signed_bits
fe78c51a 1138scm_i_inum (SCM obj)
3aa13a05
MV
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);
7888309b 1143}
7888309b 1144
c829a427
MV
1145char *
1146scm_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)
3ee86942 1155 *lenp = scm_i_string_length (obj);
c829a427
MV
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
1170char *
1171scm_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
3ee86942
MV
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). */
1196char *
1197scm_c_symbol2str (SCM obj, char *str, size_t *lenp)
1198{
1199 return scm_c_string2str (scm_symbol_to_string (obj), str, lenp);
1200}
1201
3101f40f
MV
1202double
1203scm_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
1210double
1211scm_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
6fc4d012
AW
1218SCM
1219scm_sys_expt (SCM x, SCM y)
1220{
1221 scm_c_issue_deprecation_warning
1222 ("scm_sys_expt is deprecated. Use scm_expt instead.");
1223 return scm_expt (x, y);
1224}
1225
3ee86942 1226char *
fe78c51a 1227scm_i_deprecated_symbol_chars (SCM sym)
3ee86942
MV
1228{
1229 scm_c_issue_deprecation_warning
1230 ("SCM_SYMBOL_CHARS is deprecated. Use scm_symbol_to_string.");
1231
ba16a103 1232 return (char *)scm_i_symbol_chars (sym);
3ee86942
MV
1233}
1234
1235size_t
fe78c51a 1236scm_i_deprecated_symbol_length (SCM sym)
3ee86942
MV
1237{
1238 scm_c_issue_deprecation_warning
1239 ("SCM_SYMBOL_LENGTH is deprecated. Use scm_symbol_to_string.");
ba16a103 1240 return scm_i_symbol_length (sym);
3ee86942
MV
1241}
1242
265a7997 1243int
fe78c51a 1244scm_i_keywordp (SCM obj)
265a7997
MV
1245{
1246 scm_c_issue_deprecation_warning
1247 ("SCM_KEYWORDP is deprecated. Use scm_is_keyword instead.");
1248 return scm_is_keyword (obj);
1249}
1250
1251SCM
fe78c51a 1252scm_i_keywordsym (SCM keyword)
265a7997
MV
1253{
1254 scm_c_issue_deprecation_warning
1255 ("SCM_KEYWORDSYM is deprecated. See scm_keyword_to_symbol instead.");
1256 return scm_keyword_dash_symbol (keyword);
1257}
1258
354116f7 1259int
fe78c51a 1260scm_i_vectorp (SCM x)
354116f7
MV
1261{
1262 scm_c_issue_deprecation_warning
1263 ("SCM_VECTORP is deprecated. Use scm_is_vector instead.");
1264 return SCM_I_IS_VECTOR (x);
1265}
1266
1267unsigned long
fe78c51a 1268scm_i_vector_length (SCM x)
354116f7
MV
1269{
1270 scm_c_issue_deprecation_warning
1271 ("SCM_VECTOR_LENGTH is deprecated. Use scm_c_vector_length instead.");
1272 return SCM_I_VECTOR_LENGTH (x);
1273}
1274
1275const SCM *
fe78c51a 1276scm_i_velts (SCM x)
354116f7
MV
1277{
1278 scm_c_issue_deprecation_warning
1279 ("SCM_VELTS is deprecated. Use scm_vector_elements instead.");
1280 return SCM_I_VECTOR_ELTS (x);
1281}
1282
1283SCM *
fe78c51a 1284scm_i_writable_velts (SCM x)
354116f7
MV
1285{
1286 scm_c_issue_deprecation_warning
1287 ("SCM_WRITABLE_VELTS is deprecated. "
1288 "Use scm_vector_writable_elements instead.");
1289 return SCM_I_VECTOR_WELTS (x);
1290}
1291
1292SCM
fe78c51a 1293scm_i_vector_ref (SCM x, size_t idx)
354116f7
MV
1294{
1295 scm_c_issue_deprecation_warning
1296 ("SCM_VECTOR_REF is deprecated. "
1297 "Use scm_c_vector_ref or scm_vector_elements instead.");
1298 return scm_c_vector_ref (x, idx);
1299}
1300
1301void
fe78c51a 1302scm_i_vector_set (SCM x, size_t idx, SCM val)
354116f7
MV
1303{
1304 scm_c_issue_deprecation_warning
1305 ("SCM_VECTOR_SET is deprecated. "
1306 "Use scm_c_vector_set_x or scm_vector_writable_elements instead.");
1307 scm_c_vector_set_x (x, idx, val);
1308}
1309
1310SCM
1311scm_vector_equal_p (SCM x, SCM y)
1312{
1313 scm_c_issue_deprecation_warning
1314 ("scm_vector_euqal_p is deprecated. "
1315 "Use scm_equal_p instead.");
1316 return scm_equal_p (x, y);
1317}
1318
1f366ef7 1319int
fe78c51a 1320scm_i_arrayp (SCM a)
1f366ef7
MV
1321{
1322 scm_c_issue_deprecation_warning
1323 ("SCM_ARRAYP is deprecated. Use scm_is_array instead.");
66b9d7d3 1324 return SCM_I_ARRAYP(a);
1f366ef7
MV
1325}
1326
1327size_t
fe78c51a 1328scm_i_array_ndim (SCM a)
1f366ef7
MV
1329{
1330 scm_c_issue_deprecation_warning
1331 ("SCM_ARRAY_NDIM is deprecated. "
1332 "Use scm_c_array_rank or scm_array_handle_rank instead.");
1333 return scm_c_array_rank (a);
1334}
1335
1336int
fe78c51a 1337scm_i_array_contp (SCM a)
1f366ef7
MV
1338{
1339 scm_c_issue_deprecation_warning
1340 ("SCM_ARRAY_CONTP is deprecated. Do not use it.");
1341 return SCM_I_ARRAY_CONTP (a);
1342}
1343
1344scm_t_array *
fe78c51a 1345scm_i_array_mem (SCM a)
1f366ef7
MV
1346{
1347 scm_c_issue_deprecation_warning
1348 ("SCM_ARRAY_MEM is deprecated. Do not use it.");
1349 return (scm_t_array *)SCM_I_ARRAY_MEM (a);
1350}
1351
1352SCM
fe78c51a 1353scm_i_array_v (SCM a)
1f366ef7
MV
1354{
1355 /* We could use scm_shared_array_root here, but it is better to move
1356 them away from expecting vectors as the basic storage for arrays.
1357 */
1358 scm_c_issue_deprecation_warning
1359 ("SCM_ARRAY_V is deprecated. Do not use it.");
1360 return SCM_I_ARRAY_V (a);
1361}
1362
1363size_t
fe78c51a 1364scm_i_array_base (SCM a)
1f366ef7
MV
1365{
1366 scm_c_issue_deprecation_warning
1367 ("SCM_ARRAY_BASE is deprecated. Do not use it.");
1368 return SCM_I_ARRAY_BASE (a);
1369}
1370
1371scm_t_array_dim *
fe78c51a 1372scm_i_array_dims (SCM a)
1f366ef7
MV
1373{
1374 scm_c_issue_deprecation_warning
1375 ("SCM_ARRAY_DIMS is deprecated. Use scm_array_handle_dims instead.");
1376 return SCM_I_ARRAY_DIMS (a);
1377}
1378
9de87eea
MV
1379SCM
1380scm_i_cur_inp (void)
1381{
1382 scm_c_issue_deprecation_warning
1383 ("scm_cur_inp is deprecated. Use scm_current_input_port instead.");
1384 return scm_current_input_port ();
1385}
1386
1387SCM
1388scm_i_cur_outp (void)
1389{
1390 scm_c_issue_deprecation_warning
1391 ("scm_cur_outp is deprecated. Use scm_current_output_port instead.");
1392 return scm_current_output_port ();
1393}
1394
1395SCM
1396scm_i_cur_errp (void)
1397{
1398 scm_c_issue_deprecation_warning
1399 ("scm_cur_errp is deprecated. Use scm_current_error_port instead.");
1400 return scm_current_error_port ();
1401}
1402
1403SCM
1404scm_i_cur_loadp (void)
1405{
1406 scm_c_issue_deprecation_warning
1407 ("scm_cur_loadp is deprecated. Use scm_current_load_port instead.");
1408 return scm_current_load_port ();
1409}
1410
1411SCM
1412scm_i_progargs (void)
1413{
1414 scm_c_issue_deprecation_warning
1415 ("scm_progargs is deprecated. Use scm_program_arguments instead.");
1416 return scm_program_arguments ();
1417}
1418
1419SCM
1420scm_i_deprecated_dynwinds (void)
1421{
1422 scm_c_issue_deprecation_warning
1423 ("scm_dynwinds is deprecated. Do not use it.");
1424 return scm_i_dynwinds ();
1425}
1426
9de87eea
MV
1427SCM_STACKITEM *
1428scm_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
1435int
1436scm_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
3452e666
LC
1443\f
1444/* Networking. */
1445
1040b205
LC
1446#ifdef HAVE_NETWORKING
1447
1448SCM_DEFINE (scm_inet_aton, "inet-aton", 1, 0, 0,
3452e666
LC
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
1040b205 1465SCM_DEFINE (scm_inet_ntoa, "inet-ntoa", 1, 0, 0,
3452e666
LC
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
1040b205 1481#endif /* HAVE_NETWORKING */
3452e666
LC
1482
1483\f
9de87eea
MV
1484void
1485scm_i_defer_ints_etc ()
1486{
1487 scm_c_issue_deprecation_warning
2b829bbb 1488 ("SCM_DEFER_INTS etc are deprecated. "
9de87eea
MV
1489 "Use a mutex instead if appropriate.");
1490}
1491
b8ec9dab
LC
1492int
1493scm_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
06c1d900
MV
1500SCM
1501scm_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
1509SCM
1510scm_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
1518SCM_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
1529SCM_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
1540SCM_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
760fb97d
LC
1553\f
1554/* GC-related things. */
1555
1556unsigned long scm_mallocated, scm_mtrigger;
1557size_t scm_max_segment_size;
1558
1559#if defined (GUILE_DEBUG) || defined (GUILE_DEBUG_FREELIST)
1560SCM
1561scm_map_free_list (void)
1562{
1563 return SCM_EOL;
1564}
1565#endif
1566
1567#if defined (GUILE_DEBUG_FREELIST)
1568SCM
1569scm_gc_set_debug_check_freelist_x (SCM flag)
1570{
1571 return SCM_UNSPECIFIED;
1572}
1573#endif
1574
1575\f
a3e92377
AW
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
1590scm_t_trampoline_0
1591scm_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
1598scm_t_trampoline_1
1599scm_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
1606scm_t_trampoline_2
1607scm_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
19e2247d
MV
1615void
1616scm_i_init_deprecated ()
1617{
1618#include "libguile/deprecated.x"
1619}
1620
1621#endif