diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2014-02-28 23:53:04 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2014-02-28 23:53:04 -0800 |
commit | 1784cbc15c0ca91322e2ed721ecddb848a08b2c5 (patch) | |
tree | dd9b0b94efcc0274de7aa2050ab232a77c90d639 | |
parent | ee51d5e6b411333e14f51e20713b2ad8bd930cb7 (diff) | |
download | txr-1784cbc15c0ca91322e2ed721ecddb848a08b2c5.tar.gz txr-1784cbc15c0ca91322e2ed721ecddb848a08b2c5.tar.bz2 txr-1784cbc15c0ca91322e2ed721ecddb848a08b2c5.zip |
* eval.c (self_evaluating_p, maybe_quote): New functions.
(expand): Use maybe-quote form macro-time, to not quote
result unnecessarily.
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | eval.c | 22 |
2 files changed, 27 insertions, 1 deletions
@@ -1,5 +1,11 @@ 2014-02-28 Kaz Kylheku <kaz@kylheku.com> + * eval.c (self_evaluating_p, maybe_quote): New functions. + (expand): Use maybe-quote form macro-time, to not quote + result unnecessarily. + +2014-02-28 Kaz Kylheku <kaz@kylheku.com> + * tests/011/mandel.expected: New file. * tests/011/mandel.txr: New file. @@ -1289,6 +1289,26 @@ static val maybe_progn(val forms) return if3(cdr(forms), cons(progn_s, forms), car(forms)); } +static val self_evaluating_p(val form) +{ + if (nilp(form) || form == t) + return t; + + if (symbolp(form)) + return if2(keywordp(form), t); + + if (atom(form)) + return t; + + return nil; +} + +static val maybe_quote(val form) +{ + if (self_evaluating_p(form)) + return form; + return cons(quote_s, cons(form, nil)); +} static val expand_macrolet(val form, val menv) { @@ -2476,7 +2496,7 @@ tail: val args = rest(form); val args_ex = expand_forms(args, menv); val result = eval_progn(args_ex, make_env(nil, nil, nil), args); - return cons(quote_s, cons(result, nil)); + return maybe_quote(result); } else if (sym == macrolet_s) { return expand_macrolet(form, menv); } else if (sym == symacrolet_s) { |