summaryrefslogtreecommitdiffstats
path: root/eval.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2015-05-12 06:06:45 -0700
committerKaz Kylheku <kaz@kylheku.com>2015-05-12 06:06:45 -0700
commite84cd63507d64586a7bf4ed6b1769ffd8e311a35 (patch)
tree6deff326dcf179e45729fc0e8251f54418cbbd59 /eval.c
parent6a48e98582b4b8025156fe0dc467a45b17dd4f7a (diff)
downloadtxr-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.
Diffstat (limited to 'eval.c')
-rw-r--r--eval.c36
1 files changed, 6 insertions, 30 deletions
diff --git a/eval.c b/eval.c
index 1a83aff6..04420284 100644
--- a/eval.c
+++ b/eval.c
@@ -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));
}
}