diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2015-05-12 06:06:45 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2015-05-12 06:06:45 -0700 |
commit | e84cd63507d64586a7bf4ed6b1769ffd8e311a35 (patch) | |
tree | 6deff326dcf179e45729fc0e8251f54418cbbd59 | |
parent | 6a48e98582b4b8025156fe0dc467a45b17dd4f7a (diff) | |
download | txr-e84cd63507d64586a7bf4ed6b1769ffd8e311a35.tar.gz txr-e84cd63507d64586a7bf4ed6b1769ffd8e311a35.tar.bz2 txr-e84cd63507d64586a7bf4ed6b1769ffd8e311a35.zip |
* eval.c (lookup_var_l): Gut this function of its silly
reimplementation of lookup_var.
(op_setq): Use lookup_var instead of lookup_var_l.
Now only outside modules use the lookup_var_l interface.
Error message fix: sys:setq, not setvar.
-rw-r--r-- | ChangeLog | 8 | ||||
-rw-r--r-- | eval.c | 36 |
2 files changed, 14 insertions, 30 deletions
@@ -1,3 +1,11 @@ +2015-05-12 Kaz Kylheku <kaz@kylheku.com> + + * eval.c (lookup_var_l): Gut this function of its silly + reimplementation of lookup_var. + (op_setq): Use lookup_var instead of lookup_var_l. + Now only outside modules use the lookup_var_l interface. + Error message fix: sys:setq, not setvar. + 2015-05-11 Kaz Kylheku <kaz@kylheku.com> Handle vectors and strings in rplaca and rplacd. @@ -217,32 +217,8 @@ static val lookup_sym_lisp1(val env, val sym) loc lookup_var_l(val env, val sym) { - if (env) { - type_check(env, ENV); - - for (; env; env = env->e.up_env) { - val binding = assoc(sym, env->e.vbindings); - if (binding) - return cdr_l(binding); - } - } - - for (env = dyn_env; env; env = env->e.up_env) { - val binding = assoc(sym, env->e.vbindings); - if (binding) - return cdr_l(binding); - } - - { - val binding = gethash(top_vb, sym); - if (binding) - return cdr_l(binding); - lisplib_try_load(sym); - binding = gethash(top_vb, sym); - if (binding) - return cdr_l(binding); - return nulloc; - } + val binding = lookup_var(env, sym); + return if3(binding, cdr_l(binding), nulloc); } val lookup_fun(val env, val sym) @@ -1692,12 +1668,12 @@ static val op_setq(val form, val env) val newval = pop(&args); if (!bindable(var)) { - eval_error(form, lit("setvar: ~s is not a bindable symbol"), var, nao); + eval_error(form, lit("sys:setq: ~s is not a bindable symbol"), var, nao); } else { - loc ptr = lookup_var_l(env, var); - if (nullocp(ptr)) + val binding = lookup_var(env, var); + if (nilp(binding)) eval_error(form, lit("unbound variable ~s"), var, nao); - return set(ptr, eval(newval, env, form)); + return sys_rplacd(binding, eval(newval, env, form)); } } |