summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2014-02-28 07:35:01 -0800
committerKaz Kylheku <kaz@kylheku.com>2014-02-28 16:34:09 -0800
commit8c634953700bdf3199b68e8ccf2eff4132ca81d5 (patch)
tree7e49a24d71959fd2a3c89342c090cc32d9840740
parent8083f2eec64fb7f202e31ffe050ff6aa40f5e5fd (diff)
downloadtxr-8c634953700bdf3199b68e8ccf2eff4132ca81d5.tar.gz
txr-8c634953700bdf3199b68e8ccf2eff4132ca81d5.tar.bz2
txr-8c634953700bdf3199b68e8ccf2eff4132ca81d5.zip
* eval.c (op_defvar): Remove the same-named symbol macro when a
variable is defined. (op_defsymacro): Remove the same-named variable when a symbol macro is defined. (op_defun): Throw excpetion if an attempt is made to define a special operator as a function. Remove the same-named macro when a function is defined. (op_defmacro): Throw excpetion if an attempt is made to define a special operator as a macro. REmove the same-named function when a macro is defined.
-rw-r--r--ChangeLog13
-rw-r--r--eval.c11
2 files changed, 24 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index e2b45169..bcb4b632 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,18 @@
2014-02-28 Kaz Kylheku <kaz@kylheku.com>
+ * eval.c (op_defvar): Remove the same-named symbol macro when a
+ variable is defined.
+ (op_defsymacro): Remove the same-named variable when a symbol macro is
+ defined.
+ (op_defun): Throw excpetion if an attempt is made to define a
+ special operator as a function. Remove the same-named macro when a
+ function is defined.
+ (op_defmacro): Throw excpetion if an attempt is made to define a
+ special operator as a macro. REmove the same-named function
+ when a macro is defined.
+
+2014-02-28 Kaz Kylheku <kaz@kylheku.com>
+
* eval.c (expand_qquote): Fix broken '(,x . ,y) case, which
is generating (append (list x) . y) instead of (append (list x) y).
Also, added a nil case which is now necessary to prevent
diff --git a/eval.c b/eval.c
index bfc42f18..bcd5e718 100644
--- a/eval.c
+++ b/eval.c
@@ -1199,6 +1199,7 @@ static val op_defvar(val form, val env)
{
if (!gethash(top_vb, sym)) {
val value = eval(second(args), env, form);
+ remhash(top_smb, sym);
sethash(top_vb, sym, cons(sym, value));
}
mark_special(sym);
@@ -1217,6 +1218,7 @@ static val op_defsymacro(val form, val env)
if (!bindable(sym))
eval_error(form, lit("let: ~s is not a bindable symbol"), sym, nao);
+ remhash(top_vb, sym);
sethash(top_smb, sym, cons(sym, second(args)));
return sym;
}
@@ -1235,6 +1237,11 @@ static val op_defun(val form, val env)
if (!bindable(name))
eval_error(form, lit("defun: ~s is not a bindable symbol"), name, nao);
+ if (gethash(op_table, name))
+ eval_error(form, lit("defun: ~s is a special operator"), name, nao);
+
+ remhash(top_mb, name);
+
for (iter = params; consp(iter); iter = cdr(iter)) {
val param = car(iter);
if (param == colon_k) {
@@ -1272,6 +1279,10 @@ static val op_defmacro(val form, val env)
if (!bindable(name))
eval_error(form, lit("defmacro: ~s is not a bindable symbol"), name, nao);
+ if (gethash(op_table, name))
+ eval_error(form, lit("defmacro: ~s is a special operator"), name, nao);
+
+ remhash(top_fb, name);
/* defmacro captures lexical environment, so env is passed */
sethash(top_mb, name, cons(name, cons(env, cons(params, cons(block, nil)))));
return name;