summaryrefslogtreecommitdiffstats
path: root/eval.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2013-12-17 07:15:44 -0800
committerKaz Kylheku <kaz@kylheku.com>2013-12-17 07:15:44 -0800
commitaf791d39068b7cd231497f955c0a314a31ee8881 (patch)
tree2134a7c919a06bc5b71844e05ac547df6b40d41d /eval.c
parent0c5016a7f39a6a70018949da90f3b9737bf945de (diff)
downloadtxr-af791d39068b7cd231497f955c0a314a31ee8881.tar.gz
txr-af791d39068b7cd231497f955c0a314a31ee8881.tar.bz2
txr-af791d39068b7cd231497f955c0a314a31ee8881.zip
* eval.c (op_defvar): Fix the semantics to be similar to Common Lisp:
no effect if the variable already exists. * txr.1: Documented defvar and lisp-parse.
Diffstat (limited to 'eval.c')
-rw-r--r--eval.c9
1 files changed, 3 insertions, 6 deletions
diff --git a/eval.c b/eval.c
index 3c4aa120..c0adfa0c 100644
--- a/eval.c
+++ b/eval.c
@@ -721,13 +721,10 @@ static val op_defvar(val form, val env)
eval_error(form, lit("let: ~s is not a bindable sybol"), sym, nao);
{
- val value = eval(second(args), env, form);
- val existing = gethash(top_vb, sym);
-
- if (existing)
- set(*cdr_l(existing), value);
- else
+ if (!gethash(top_vb, sym)) {
+ val value = eval(second(args), env, form);
sethash(top_vb, sym, cons(sym, value));
+ }
}
return sym;