* Deprecated scm_makfromstr and added scm_mem2string as a replacement.
[bpt/guile.git] / libguile / modules.c
CommitLineData
729dbac3 1/* Copyright (C) 1998,2000,2001 Free Software Foundation, Inc.
1ffa265b
MD
2 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2, or (at your option)
6 * any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this software; see the file COPYING. If not, write to
15 * the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
16 * Boston, MA 02111-1307 USA
17 *
18 * As a special exception, the Free Software Foundation gives permission
19 * for additional uses of the text contained in its release of GUILE.
20 *
21 * The exception is that, if you link the GUILE library with other files
22 * to produce an executable, this does not by itself cause the
23 * resulting executable to be covered by the GNU General Public License.
24 * Your use of that executable is in no way restricted on account of
25 * linking the GUILE library code into it.
26 *
27 * This exception does not however invalidate any other reasons why
28 * the executable file might be covered by the GNU General Public License.
29 *
30 * This exception applies only to the code released by the
31 * Free Software Foundation under the name GUILE. If you copy
32 * code from other Free Software Foundation releases into a copy of
33 * GUILE, as the General Public License permits, the exception does
34 * not apply to the code that you add in this way. To avoid misleading
35 * anyone as to the status of such modified files, you must delete
36 * this exception notice from them.
37 *
38 * If you write modifications of your own for GUILE, it is your choice
39 * whether to permit this exception to apply to your modifications.
40 * If you do not wish that, delete this exception notice. */
6e8d25a6
GB
41
42/* Software engineering face-lift by Greg J. Badros, 11-Dec-1999,
43 gjb@cs.washington.edu, http://www.cs.washington.edu/homes/gjb */
44
1ffa265b
MD
45\f
46
d02b98e9
MV
47#include <stdarg.h>
48
a0599745 49#include "libguile/_scm.h"
1ffa265b 50
a0599745 51#include "libguile/eval.h"
fb43bf74 52#include "libguile/smob.h"
a0599745 53#include "libguile/procprop.h"
152abe96
MD
54#include "libguile/vectors.h"
55#include "libguile/hashtab.h"
56#include "libguile/struct.h"
57#include "libguile/variable.h"
7f763132 58#include "libguile/fluids.h"
d02b98e9 59#include "libguile/deprecation.h"
1ffa265b 60
a0599745 61#include "libguile/modules.h"
1ffa265b 62
86d31dfe 63int scm_module_system_booted_p = 0;
e3365c07 64
92c2555f 65scm_t_bits scm_module_tag;
e3365c07 66
1ffa265b
MD
67static SCM the_module;
68
55000e5f
MV
69SCM_DEFINE (scm_current_module, "current-module", 0, 0, 0,
70 (),
71 "Return the current module.")
72#define FUNC_NAME s_scm_current_module
1ffa265b 73{
55000e5f 74 return scm_fluid_ref (the_module);
1ffa265b 75}
55000e5f 76#undef FUNC_NAME
1ffa265b 77
86d31dfe 78static void scm_post_boot_init_modules (void);
1ffa265b 79
55000e5f
MV
80SCM_DEFINE (scm_set_current_module, "set-current-module", 1, 0, 0,
81 (SCM module),
82 "Set the current module to @var{module} and return"
83 "the previous current module.")
84#define FUNC_NAME s_scm_set_current_module
1ffa265b 85{
55000e5f
MV
86 SCM old;
87
86d31dfe
MV
88 if (!scm_module_system_booted_p)
89 scm_post_boot_init_modules ();
90
91 SCM_VALIDATE_MODULE (SCM_ARG1, module);
55000e5f
MV
92
93 old = scm_current_module ();
94 scm_fluid_set_x (the_module, module);
95
96#if SCM_DEBUG_DEPRECATED == 0
86d31dfe 97 scm_fluid_set_x (SCM_VARIABLE_REF (scm_top_level_lookup_closure_var),
55000e5f 98 scm_current_module_lookup_closure ());
86d31dfe 99 scm_fluid_set_x (SCM_VARIABLE_REF (scm_system_transformer),
55000e5f
MV
100 scm_current_module_transformer ());
101#endif
102
1ffa265b
MD
103 return old;
104}
55000e5f 105#undef FUNC_NAME
1ffa265b 106
e3365c07
MD
107SCM_DEFINE (scm_interaction_environment, "interaction-environment", 0, 0, 0,
108 (),
1e6808ea
MG
109 "Return a specifier for the environment that contains\n"
110 "implementation--defined bindings, typically a superset of those\n"
111 "listed in the report. The intent is that this procedure will\n"
112 "return the environment in which the implementation would\n"
113 "evaluate expressions dynamically typed by the user.")
e3365c07
MD
114#define FUNC_NAME s_scm_interaction_environment
115{
aa767bc5 116 return scm_current_module ();
e3365c07
MD
117}
118#undef FUNC_NAME
119
1ffa265b 120SCM
d02b98e9
MV
121scm_c_call_with_current_module (SCM module,
122 SCM (*func)(void *), void *data)
1ffa265b 123{
d02b98e9 124 return scm_c_with_fluid (the_module, module, func, data);
1ffa265b
MD
125}
126
d02b98e9
MV
127static SCM
128convert_module_name (const char *name)
281004cc 129{
d02b98e9
MV
130 SCM list = SCM_EOL;
131 SCM *tail = &list;
281004cc 132
d02b98e9
MV
133 const char *ptr;
134 while (*name)
135 {
136 while (*name == ' ')
137 name++;
138 ptr = name;
139 while (*ptr && *ptr != ' ')
140 ptr++;
141 if (ptr > name)
142 {
143 *tail = scm_cons (scm_mem2symbol (name, ptr-name), SCM_EOL);
144 tail = SCM_CDRLOC (*tail);
145 }
146 name = ptr;
147 }
148
149 return list;
1ffa265b
MD
150}
151
d02b98e9
MV
152static SCM process_define_module_var;
153static SCM process_use_modules_var;
154static SCM resolve_module_var;
155
9e57344b 156SCM
d02b98e9 157scm_c_resolve_module (const char *name)
9e57344b 158{
d02b98e9 159 return scm_resolve_module (convert_module_name (name));
9e57344b
MV
160}
161
55000e5f 162SCM
d02b98e9 163scm_resolve_module (SCM name)
55000e5f 164{
d02b98e9
MV
165 return scm_apply (SCM_VARIABLE_REF (resolve_module_var),
166 SCM_LIST1 (name), SCM_EOL);
55000e5f
MV
167}
168
169SCM
d02b98e9
MV
170scm_c_define_module (const char *name,
171 void (*init)(void *), void *data)
55000e5f 172{
d02b98e9
MV
173 SCM module = scm_apply (SCM_VARIABLE_REF (process_define_module_var),
174 SCM_LIST1 (SCM_LIST1 (convert_module_name (name))),
175 SCM_EOL);
176 if (init)
177 scm_c_call_with_current_module (module, (SCM (*)(void*))init, data);
178 return module;
55000e5f
MV
179}
180
d02b98e9
MV
181void
182scm_c_use_module (const char *name)
90184345 183{
d02b98e9
MV
184 scm_apply (SCM_VARIABLE_REF (process_use_modules_var),
185 SCM_LIST1 (SCM_LIST1 (convert_module_name (name))),
186 SCM_EOL);
90184345
MD
187}
188
d02b98e9 189static SCM module_export_x_var;
281004cc 190
d02b98e9
MV
191void
192scm_c_export (const char *name, ...)
281004cc 193{
d02b98e9
MV
194 va_list ap;
195 SCM names = scm_cons (scm_str2symbol (name), SCM_EOL);
196 SCM *tail = SCM_CDRLOC (names);
197 va_start (ap, name);
198 while (1)
199 {
200 const char *n = va_arg (ap, const char *);
201 if (n == NULL)
202 break;
203 *tail = scm_cons (scm_str2symbol (n), SCM_EOL);
204 tail = SCM_CDRLOC (*tail);
205 }
206 scm_apply (SCM_VARIABLE_REF (module_export_x_var),
207 SCM_LIST2 (scm_current_module (),
208 names),
209 SCM_EOL);
281004cc
MD
210}
211
e3365c07 212/* Environments */
d164a5af
MD
213
214SCM
6e8d25a6 215scm_top_level_env (SCM thunk)
d164a5af
MD
216{
217 if (SCM_IMP (thunk))
218 return SCM_EOL;
219 else
220 return scm_cons (thunk, SCM_EOL);
221}
222
223SCM
224scm_env_top_level (SCM env)
225{
226 while (SCM_NIMP (env))
227 {
228 if (!SCM_CONSP (SCM_CAR (env))
229 && SCM_NFALSEP (scm_procedure_p (SCM_CAR (env))))
c15c33ee 230 return SCM_CAR (env);
d164a5af
MD
231 env = SCM_CDR (env);
232 }
233 return SCM_BOOL_F;
234}
235
86d31dfe
MV
236SCM_SYMBOL (sym_module, "module");
237
d02b98e9
MV
238static SCM the_root_module_var;
239
240static SCM
241the_root_module ()
242{
243 if (scm_module_system_booted_p)
244 return SCM_VARIABLE_REF (the_root_module_var);
245 else
246 return SCM_BOOL_F;
247}
248
86d31dfe
MV
249SCM
250scm_lookup_closure_module (SCM proc)
251{
252 if (SCM_FALSEP (proc))
d02b98e9 253 return the_root_module ();
86d31dfe
MV
254 else if (SCM_EVAL_CLOSURE_P (proc))
255 return SCM_PACK (SCM_SMOB_DATA (proc));
256 else
257 {
258 SCM mod = scm_procedure_property (proc, sym_module);
259 if (mod == SCM_BOOL_F)
d02b98e9 260 mod = the_root_module ();
86d31dfe
MV
261 return mod;
262 }
263}
264
e24ca538
MV
265SCM_DEFINE (scm_env_module, "env-module", 1, 0, 0,
266 (SCM env),
267 "Return the module of @var{ENV}, a lexical environment.")
268#define FUNC_NAME s_scm_env_module
86d31dfe
MV
269{
270 return scm_lookup_closure_module (scm_env_top_level (env));
271}
e24ca538 272#undef FUNC_NAME
86d31dfe 273
152abe96
MD
274/*
275 * C level implementation of the standard eval closure
276 *
277 * This increases loading speed substantially.
278 * The code will be replaced by the low-level environments in next release.
279 */
280
86d31dfe 281static SCM module_make_local_var_x_var;
152abe96
MD
282
283static SCM
284module_variable (SCM module, SCM sym)
285{
286 /* 1. Check module obarray */
e3365c07 287 SCM b = scm_hashq_ref (SCM_MODULE_OBARRAY (module), sym, SCM_UNDEFINED);
152abe96
MD
288 if (SCM_VARIABLEP (b))
289 return b;
290 {
e3365c07 291 SCM binder = SCM_MODULE_BINDER (module);
152abe96
MD
292 if (SCM_NFALSEP (binder))
293 /* 2. Custom binder */
294 {
295 b = scm_apply (binder,
296 SCM_LIST3 (module, sym, SCM_BOOL_F),
297 SCM_EOL);
298 if (SCM_NFALSEP (b))
299 return b;
300 }
301 }
302 {
303 /* 3. Search the use list */
e3365c07 304 SCM uses = SCM_MODULE_USES (module);
152abe96
MD
305 while (SCM_CONSP (uses))
306 {
307 b = module_variable (SCM_CAR (uses), sym);
308 if (SCM_NFALSEP (b))
309 return b;
310 uses = SCM_CDR (uses);
311 }
312 return SCM_BOOL_F;
313 }
314}
315
92c2555f 316scm_t_bits scm_tc16_eval_closure;
152abe96 317
86d31dfe
MV
318#define SCM_F_EVAL_CLOSURE_INTERFACE (1<<16)
319#define SCM_EVAL_CLOSURE_INTERFACE_P(e) \
320 (SCM_CELL_WORD_0 (e) & SCM_F_EVAL_CLOSURE_INTERFACE)
321
fb43bf74
KN
322/* NOTE: This function may be called by a smob application
323 or from another C function directly. */
324SCM
325scm_eval_closure_lookup (SCM eclo, SCM sym, SCM definep)
152abe96 326{
fb43bf74 327 SCM module = SCM_PACK (SCM_SMOB_DATA (eclo));
152abe96 328 if (SCM_NFALSEP (definep))
86d31dfe
MV
329 {
330 if (SCM_EVAL_CLOSURE_INTERFACE_P (eclo))
331 return SCM_BOOL_F;
332 return scm_apply (SCM_VARIABLE_REF (module_make_local_var_x_var),
333 SCM_LIST2 (module, sym),
334 SCM_EOL);
335 }
152abe96
MD
336 else
337 return module_variable (module, sym);
338}
339
340SCM_DEFINE (scm_standard_eval_closure, "standard-eval-closure", 1, 0, 0,
341 (SCM module),
84526793 342 "Return an eval closure for the module @var{module}.")
152abe96
MD
343#define FUNC_NAME s_scm_standard_eval_closure
344{
e841c3e0 345 SCM_RETURN_NEWSMOB (scm_tc16_eval_closure, SCM_UNPACK (module));
152abe96
MD
346}
347#undef FUNC_NAME
348
86d31dfe
MV
349SCM_DEFINE (scm_standard_interface_eval_closure,
350 "standard-interface-eval-closure", 1, 0, 0,
351 (SCM module),
352 "Return a interface eval closure for the module @var{module}. "
353 "Such a closure does not allow new bindings to be added.")
354#define FUNC_NAME s_scm_standard_interface_eval_closure
355{
356 SCM_RETURN_NEWSMOB (scm_tc16_eval_closure | SCM_F_EVAL_CLOSURE_INTERFACE,
357 SCM_UNPACK (module));
358}
359#undef FUNC_NAME
360
d02b98e9
MV
361SCM
362scm_module_lookup_closure (SCM module)
363{
364 if (module == SCM_BOOL_F)
365 return SCM_BOOL_F;
366 else
367 return SCM_MODULE_EVAL_CLOSURE (module);
368}
369
370SCM
371scm_current_module_lookup_closure ()
372{
373 if (scm_module_system_booted_p)
374 return scm_module_lookup_closure (scm_current_module ());
375 else
376 return SCM_BOOL_F;
377}
378
379SCM
380scm_module_transformer (SCM module)
381{
382 if (module == SCM_BOOL_F)
383 return SCM_BOOL_F;
384 else
385 return SCM_MODULE_TRANSFORMER (module);
386}
387
388SCM
389scm_current_module_transformer ()
390{
391 if (scm_module_system_booted_p)
392 return scm_module_transformer (scm_current_module ());
393 else
394 return SCM_BOOL_F;
395}
396
86d31dfe
MV
397/* scm_sym2var
398 *
399 * looks up the variable bound to SYM according to PROC. PROC should be
400 * a `eval closure' of some module.
401 *
402 * When no binding exists, and DEFINEP is true, create a new binding
403 * with a initial value of SCM_UNDEFINED. Return `#f' when DEFINEP as
404 * false and no binding exists.
405 *
406 * When PROC is `#f', it is ignored and the binding is searched for in
407 * the scm_pre_modules_obarray (a `eq' hash table).
408 */
409
410SCM scm_pre_modules_obarray;
411
412SCM
413scm_sym2var (SCM sym, SCM proc, SCM definep)
414#define FUNC_NAME "scm_sym2var"
415{
416 SCM var;
417
418 if (SCM_NIMP (proc))
419 {
420 if (SCM_EVAL_CLOSURE_P (proc))
421 {
422 /* Bypass evaluator in the standard case. */
423 var = scm_eval_closure_lookup (proc, sym, definep);
424 }
425 else
426 var = scm_apply (proc, sym, scm_cons (definep, scm_listofnull));
427 }
428 else
429 {
430 SCM handle;
431
432 if (definep == SCM_BOOL_F)
433 var = scm_hashq_ref (scm_pre_modules_obarray, sym, SCM_BOOL_F);
434 else
435 {
436 handle = scm_hashq_create_handle_x (scm_pre_modules_obarray,
437 sym, SCM_BOOL_F);
438 var = SCM_CDR (handle);
439 if (var == SCM_BOOL_F)
440 {
441 var = scm_make_variable (SCM_UNDEFINED);
442#if SCM_ENABLE_VCELLS
443 scm_variable_set_name_hint (var, sym);
444#endif
445 SCM_SETCDR (handle, var);
446 }
447 }
448 }
449
450 if (var != SCM_BOOL_F && !SCM_VARIABLEP (var))
451 SCM_MISC_ERROR ("~S is not bound to a variable", SCM_LIST1 (sym));
452
453 return var;
454}
455#undef FUNC_NAME
456
457SCM
458scm_c_module_lookup (SCM module, const char *name)
459{
460 return scm_module_lookup (module, scm_str2symbol (name));
461}
462
463SCM
464scm_module_lookup (SCM module, SCM sym)
465#define FUNC_NAME "module-lookup"
466{
467 SCM var;
468 SCM_VALIDATE_MODULE (1, module);
469
470 var = scm_sym2var (sym, scm_module_lookup_closure (module), SCM_BOOL_F);
471 if (SCM_FALSEP (var))
472 SCM_MISC_ERROR ("unbound variable: ~S", SCM_LIST1 (sym));
473 return var;
474}
475#undef FUNC_NAME
476
477SCM
478scm_c_lookup (const char *name)
479{
480 return scm_lookup (scm_str2symbol (name));
481}
482
483SCM
484scm_lookup (SCM sym)
485{
486 SCM var =
487 scm_sym2var (sym, scm_current_module_lookup_closure (), SCM_BOOL_F);
488 if (SCM_FALSEP (var))
489 scm_misc_error ("scm_lookup", "unbound variable: ~S", SCM_LIST1 (sym));
490 return var;
491}
492
493SCM
494scm_c_module_define (SCM module, const char *name, SCM value)
495{
496 return scm_module_define (module, scm_str2symbol (name), value);
497}
498
499SCM
500scm_module_define (SCM module, SCM sym, SCM value)
501#define FUNC_NAME "module-define"
502{
503 SCM var;
504 SCM_VALIDATE_MODULE (1, module);
505
506 var = scm_sym2var (sym, scm_module_lookup_closure (module), SCM_BOOL_T);
507 SCM_VARIABLE_SET (var, value);
508 return var;
509}
510#undef FUNC_NAME
511
512SCM
513scm_c_define (const char *name, SCM value)
514{
515 return scm_define (scm_str2symbol (name), value);
516}
517
518SCM
519scm_define (SCM sym, SCM value)
520{
521 SCM var =
522 scm_sym2var (sym, scm_current_module_lookup_closure (), SCM_BOOL_T);
523 SCM_VARIABLE_SET (var, value);
524 return var;
525}
526
527SCM
528scm_module_reverse_lookup (SCM module, SCM variable)
529#define FUNC_NAME "module-reverse-lookup"
530{
531 SCM obarray;
c014a02e 532 long i, n;
86d31dfe
MV
533
534 if (module == SCM_BOOL_F)
535 obarray = scm_pre_modules_obarray;
536 else
537 {
538 SCM_VALIDATE_MODULE (1, module);
539 obarray = SCM_MODULE_OBARRAY (module);
540 }
541
542 /* XXX - We do not use scm_hash_fold here to avoid searching the
543 whole obarray. We should have a scm_hash_find procedure. */
544
545 n = SCM_VECTOR_LENGTH (obarray);
546 for (i = 0; i < n; ++i)
547 {
548 SCM ls = SCM_VELTS (obarray)[i], handle;
549 while (!SCM_NULLP (ls))
550 {
551 handle = SCM_CAR (ls);
552 if (SCM_CDR (handle) == variable)
553 return SCM_CAR (handle);
554 ls = SCM_CDR (ls);
555 }
556 }
557
558 /* Try the `uses' list.
559 */
560 {
561 SCM uses = SCM_MODULE_USES (module);
562 while (SCM_CONSP (uses))
563 {
564 SCM sym = scm_module_reverse_lookup (SCM_CAR (uses), variable);
565 if (sym != SCM_BOOL_F)
566 return sym;
567 uses = SCM_CDR (uses);
568 }
569 }
570
571 return SCM_BOOL_F;
572}
573#undef FUNC_NAME
574
575SCM_DEFINE (scm_get_pre_modules_obarray, "%get-pre-modules-obarray", 0, 0, 0,
576 (),
577 "Return the obarray that is used for all new bindings before "
578 "the module system is booted. The first call to "
579 "@code{set-current-module} will boot the module system.")
580#define FUNC_NAME s_scm_get_pre_modules_obarray
581{
582 return scm_pre_modules_obarray;
583}
584#undef FUNC_NAME
585
d02b98e9
MV
586#if SCM_DEBUG_DEPRECATED == 0
587
588static SCM root_module_lookup_closure;
589SCM_SYMBOL (scm_sym_app, "app");
590SCM_SYMBOL (scm_sym_modules, "modules");
591static SCM module_prefix;
592static SCM make_modules_in_var;
593static SCM beautify_user_module_x_var;
594static SCM try_module_autoload_var;
595
596#endif
597
598SCM_SYMBOL (scm_sym_system_module, "system-module");
599
600SCM
601scm_system_module_env_p (SCM env)
602{
603 SCM proc = scm_env_top_level (env);
604 if (SCM_FALSEP (proc))
605 return SCM_BOOL_T;
606 return ((SCM_NFALSEP (scm_procedure_property (proc,
607 scm_sym_system_module)))
608 ? SCM_BOOL_T
609 : SCM_BOOL_F);
610}
611
86d31dfe
MV
612void
613scm_modules_prehistory ()
614{
615 scm_pre_modules_obarray
616 = scm_permanent_object (scm_c_make_hash_table (2001));
617}
618
1ffa265b
MD
619void
620scm_init_modules ()
621{
8dc9439f 622#ifndef SCM_MAGIC_SNARFER
a0599745 623#include "libguile/modules.x"
8dc9439f 624#endif
86d31dfe
MV
625 module_make_local_var_x_var = scm_c_define ("module-make-local-var!",
626 SCM_UNDEFINED);
e841c3e0
KN
627 scm_tc16_eval_closure = scm_make_smob_type ("eval-closure", 0);
628 scm_set_smob_mark (scm_tc16_eval_closure, scm_markcdr);
629 scm_set_smob_apply (scm_tc16_eval_closure, scm_eval_closure_lookup, 2, 0, 0);
55000e5f
MV
630
631 the_module = scm_permanent_object (scm_make_fluid ());
1ffa265b
MD
632}
633
86d31dfe 634static void
1ffa265b
MD
635scm_post_boot_init_modules ()
636{
86d31dfe
MV
637#define PERM(x) scm_permanent_object(x)
638
639 SCM module_type = SCM_VARIABLE_REF (scm_c_lookup ("module-type"));
640 scm_module_tag = (SCM_CELL_WORD_1 (module_type) + scm_tc3_cons_gloc);
d02b98e9
MV
641
642 resolve_module_var = PERM (scm_c_lookup ("resolve-module"));
643 process_define_module_var = PERM (scm_c_lookup ("process-define-module"));
644 process_use_modules_var = PERM (scm_c_lookup ("process-use-modules"));
645 module_export_x_var = PERM (scm_c_lookup ("module-export!"));
646 the_root_module_var = PERM (scm_c_lookup ("the-root-module"));
647
648#if SCM_DEBUG_DEPRECATED == 0
649
86d31dfe
MV
650 module_prefix = PERM (SCM_LIST2 (scm_sym_app, scm_sym_modules));
651 make_modules_in_var = PERM (scm_c_lookup ("make-modules-in"));
86d31dfe
MV
652 root_module_lookup_closure =
653 PERM (scm_module_lookup_closure (SCM_VARIABLE_REF (the_root_module_var)));
d02b98e9 654 beautify_user_module_x_var = PERM (scm_c_lookup ("beautify-user-module!"));
86d31dfe 655 try_module_autoload_var = PERM (scm_c_lookup ("try-module-autoload"));
d02b98e9
MV
656
657#endif
658
e3365c07 659 scm_module_system_booted_p = 1;
1ffa265b 660}
89e00824 661
d02b98e9
MV
662#if SCM_DEBUG_DEPRECATED == 0
663
664SCM
665scm_the_root_module ()
666{
667 scm_c_issue_deprecation_warning ("`scm_the_root_module' is deprecated. "
668 "Use `scm_c_resolve_module (\"guile\") "
669 "instead.");
670
671 return the_root_module ();
672}
673
674static SCM
675scm_module_full_name (SCM name)
676{
677 if (SCM_EQ_P (SCM_CAR (name), scm_sym_app))
678 return name;
679 else
680 return scm_append (SCM_LIST2 (module_prefix, name));
681}
682
683SCM
684scm_make_module (SCM name)
685{
686 scm_c_issue_deprecation_warning ("`scm_make_module' is deprecated. "
687 "Use `scm_c_define_module instead.");
688
689 return scm_apply (SCM_VARIABLE_REF (make_modules_in_var),
690 SCM_LIST2 (scm_the_root_module (),
691 scm_module_full_name (name)),
692 SCM_EOL);
693}
694
695SCM
696scm_ensure_user_module (SCM module)
697{
698 scm_c_issue_deprecation_warning ("`scm_ensure_user_module' is deprecated. "
699 "Use `scm_c_define_module instead.");
700
701 scm_apply (SCM_VARIABLE_REF (beautify_user_module_x_var),
702 SCM_LIST1 (module), SCM_EOL);
703 return SCM_UNSPECIFIED;
704}
705
706SCM
707scm_load_scheme_module (SCM name)
708{
709 scm_c_issue_deprecation_warning ("`scm_load_scheme_module' is deprecated. "
710 "Use `scm_c_resolve_module instead.");
711
712 return scm_apply (SCM_VARIABLE_REF (try_module_autoload_var),
713 SCM_LIST1 (name), SCM_EOL);
714}
715
716#endif
717
89e00824
ML
718/*
719 Local Variables:
720 c-file-style: "gnu"
721 End:
722*/