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:
Alex Shinn 2011-12-01 21:54:56 +09:00
parent 5847e6b631
commit 75f67b5474
2 changed files with 5 additions and 2 deletions

5
main.c
View file

@ -411,7 +411,10 @@ void run_main (int argc, char **argv) {
#if SEXP_USE_MODULES
/* reset the environment to have only the `import' binding */
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);
tmp = sexp_env_ref(sexp_global(ctx, SEXP_G_META_ENV), sym, SEXP_VOID);
sym = sexp_intern(ctx, "import", -1);

View file

@ -1344,7 +1344,7 @@
(define (generate file)
(display "/* automatically generated by chibi genstubs */\n")
(c-system-include "chibi/eval.h")
(load file (current-environment))
(load file)
(write-init))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;