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