diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2014-02-28 07:35:01 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2014-02-28 16:34:09 -0800 |
commit | 8c634953700bdf3199b68e8ccf2eff4132ca81d5 (patch) | |
tree | 7e49a24d71959fd2a3c89342c090cc32d9840740 | |
parent | 8083f2eec64fb7f202e31ffe050ff6aa40f5e5fd (diff) | |
download | txr-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-- | ChangeLog | 13 | ||||
-rw-r--r-- | eval.c | 11 |
2 files changed, 24 insertions, 0 deletions
@@ -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 @@ -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; |