mirror of
https://github.com/ashinn/chibi-scheme.git
synced 2025-07-05 04:06:36 +02:00
Setting interaction environment to load environment when running scripts.
This maintains backwards compatibility, and is convenient in many cases. If you want to run a script which really does want an interaction-environment, such as a repl or editor, you should reset the env to a fresh one.
This commit is contained in:
parent
5847e6b631
commit
75f67b5474
2 changed files with 5 additions and 2 deletions
5
main.c
5
main.c
|
@ -411,7 +411,10 @@ void run_main (int argc, char **argv) {
|
||||||
#if SEXP_USE_MODULES
|
#if SEXP_USE_MODULES
|
||||||
/* reset the environment to have only the `import' binding */
|
/* reset the environment to have only the `import' binding */
|
||||||
if (!mods_loaded) {
|
if (!mods_loaded) {
|
||||||
sexp_context_env(ctx) = env = sexp_make_env(ctx);
|
env = sexp_make_env(ctx);
|
||||||
|
sexp_set_parameter(ctx, sexp_context_env(ctx),
|
||||||
|
sexp_global(ctx, SEXP_G_INTERACTION_ENV_SYMBOL), env);
|
||||||
|
sexp_context_env(ctx) = env;
|
||||||
sym = sexp_intern(ctx, "repl-import", -1);
|
sym = sexp_intern(ctx, "repl-import", -1);
|
||||||
tmp = sexp_env_ref(sexp_global(ctx, SEXP_G_META_ENV), sym, SEXP_VOID);
|
tmp = sexp_env_ref(sexp_global(ctx, SEXP_G_META_ENV), sym, SEXP_VOID);
|
||||||
sym = sexp_intern(ctx, "import", -1);
|
sym = sexp_intern(ctx, "import", -1);
|
||||||
|
|
|
@ -1344,7 +1344,7 @@
|
||||||
(define (generate file)
|
(define (generate file)
|
||||||
(display "/* automatically generated by chibi genstubs */\n")
|
(display "/* automatically generated by chibi genstubs */\n")
|
||||||
(c-system-include "chibi/eval.h")
|
(c-system-include "chibi/eval.h")
|
||||||
(load file (current-environment))
|
(load file)
|
||||||
(write-init))
|
(write-init))
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
|
Loading…
Add table
Reference in a new issue