summaryrefslogtreecommitdiffstats
path: root/parser.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2016-09-23 21:38:50 -0700
committerKaz Kylheku <kaz@kylheku.com>2016-09-23 21:38:50 -0700
commitd510a260dd1755961fe85b6653e9832f49b34201 (patch)
treef540fedfaed3c0becb8808a7b97c602efb8fd4ac /parser.c
parent57f625f68909a4420e5621a2f40717427ecf63e2 (diff)
downloadtxr-d510a260dd1755961fe85b6653e9832f49b34201.tar.gz
txr-d510a260dd1755961fe85b6653e9832f49b34201.tar.bz2
txr-d510a260dd1755961fe85b6653e9832f49b34201.zip
Bugfix: -Dvar=val not seen in some Lisp code.
TXR Lisp files run from the command line do not see -Dvar=val bindings, whereas -p expressions do. The REPL sees the bindings, but not code loaded from it using (load "file.tl") because they are lexical. Let's keep these bindings as local lexicals for -p and -e forms, but install them as global lexicals for the other situations. * parser.c (repl): Get rid of the local repl_env made from the bindings that are passed in. Instead, before starting the REPL, loop through the bindings and install them as global lexicals with reg_varl. * txr.c (txr_main): Before processing a Lisp file, install the bindings as global lexicals with reg_varl.
Diffstat (limited to 'parser.c')
-rw-r--r--parser.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/parser.c b/parser.c
index aca71939..88e24475 100644
--- a/parser.c
+++ b/parser.c
@@ -667,7 +667,6 @@ val repl(val bindings, val in_stream, val out_stream)
lino_t *ls = lino_make(c_num(ifd), c_num(ofd));
char *line_u8 = 0;
char *prompt_u8 = 0;
- val repl_env = make_env(bindings, nil, nil);
val quit_k = intern(lit("quit"), keyword_package);
val read_k = intern(lit("read"), keyword_package);
val counter_sym = intern(lit("*n"), user_package);
@@ -686,6 +685,11 @@ val repl(val bindings, val in_stream, val out_stream)
val multi_line_var = lookup_global_var(listener_multi_line_p_s);
val sel_inclusive_var = lookup_global_var(listener_sel_inclusive_p_s);
+ for (; bindings; bindings = cdr(bindings)) {
+ val binding = car(bindings);
+ reg_varl(car(binding), cdr(binding));
+ }
+
reg_varl(result_hash_sym, result_hash);
lino_set_completion_cb(ls, provide_completions, 0);
@@ -761,8 +765,8 @@ val repl(val bindings, val in_stream, val out_stream)
done = t;
} else {
val value = if3(form != read_k,
- eval_intrinsic(form, repl_env),
- read_eval_ret_last(repl_env, prev_counter,
+ eval_intrinsic(form, nil),
+ read_eval_ret_last(nil, prev_counter,
in_stream, out_stream));
reg_varl(var_sym, value);
sethash(result_hash, var_counter, value);