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