summaryrefslogtreecommitdiffstats
path: root/eval.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2014-03-21 23:24:40 -0700
committerKaz Kylheku <kaz@kylheku.com>2014-03-22 11:52:56 -0700
commit654a913f119664bce805fb2da94bcee0349ab7fb (patch)
treeda63867f8ec40ab0818851139b2491841027baf4 /eval.c
parent3e17fb079dcecebded6e7d8c834b918d9a3b541a (diff)
downloadtxr-654a913f119664bce805fb2da94bcee0349ab7fb.tar.gz
txr-654a913f119664bce805fb2da94bcee0349ab7fb.tar.bz2
txr-654a913f119664bce805fb2da94bcee0349ab7fb.zip
* eval.c (me_when): New static function.
(eval_init): Register "when" macro. * txr.1: Documented when macro.
Diffstat (limited to 'eval.c')
-rw-r--r--eval.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/eval.c b/eval.c
index b0213253..ba287c5c 100644
--- a/eval.c
+++ b/eval.c
@@ -2021,6 +2021,12 @@ static val me_pprof(val form, val menv)
nao);
}
+static val me_when(val form, val menv)
+{
+ (void) menv;
+ return cons(cond_s, cons(rest(form), nil));
+}
+
val expand_forms(val form, val menv)
{
if (atom(form)) {
@@ -3179,6 +3185,7 @@ void eval_init(void)
reg_mac(qquote_s, me_qquote);
reg_mac(sys_qquote_s, me_qquote);
reg_mac(intern(lit("pprof"), user_package), me_pprof);
+ reg_mac(intern(lit("when"), user_package), me_when);
reg_fun(cons_s, func_n2(cons));
reg_fun(intern(lit("make-lazy-cons"), user_package), func_n1(make_lazy_cons));