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