summaryrefslogtreecommitdiffstats
path: root/eval.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2014-02-28 23:53:04 -0800
committerKaz Kylheku <kaz@kylheku.com>2014-02-28 23:53:04 -0800
commit1784cbc15c0ca91322e2ed721ecddb848a08b2c5 (patch)
treedd9b0b94efcc0274de7aa2050ab232a77c90d639 /eval.c
parentee51d5e6b411333e14f51e20713b2ad8bd930cb7 (diff)
downloadtxr-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.
Diffstat (limited to 'eval.c')
-rw-r--r--eval.c22
1 files changed, 21 insertions, 1 deletions
diff --git a/eval.c b/eval.c
index 89b9c5b5..87398d64 100644
--- a/eval.c
+++ b/eval.c
@@ -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) {