summaryrefslogtreecommitdiffstats
path: root/eval.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2015-10-09 21:38:07 -0700
committerKaz Kylheku <kaz@kylheku.com>2015-10-09 21:38:07 -0700
commit29ccb2c2b33dd4b8d628d0499fa46799f6762ddb (patch)
treed2a0532ad98409210325ebeadf698fe9b9c25648 /eval.c
parent9a3db7ec38ec3a5e1810d86f67c0bcbe62ba2359 (diff)
downloadtxr-29ccb2c2b33dd4b8d628d0499fa46799f6762ddb.tar.gz
txr-29ccb2c2b33dd4b8d628d0499fa46799f6762ddb.tar.bz2
txr-29ccb2c2b33dd4b8d628d0499fa46799f6762ddb.zip
Tweaking expansions of when and until.
* eval.c (me_when): Expand to if if there aren't multiple body forms. (me_unless): Simplify progn. * tests/012/struct.tl: Update string representation in struct test case.
Diffstat (limited to 'eval.c')
-rw-r--r--eval.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/eval.c b/eval.c
index ad0b8bdd..23afd828 100644
--- a/eval.c
+++ b/eval.c
@@ -52,6 +52,7 @@
#include "txr.h"
#include "combi.h"
#include "lisplib.h"
+#include "cadr.h"
#include "eval.h"
#define max(a, b) ((a) > (b) ? (a) : (b))
@@ -2080,13 +2081,20 @@ static val me_pprof(val form, val menv)
static val me_when(val form, val menv)
{
(void) menv;
- return cons(cond_s, cons(rest(form), nil));
+
+ return if3(cdddr(form),
+ cons(cond_s, cons(cdr(form), nil)),
+ cons(if_s, cdr(form)));
}
static val me_unless(val form, val menv)
{
+ val test = cadr(form);
+ val body = cddr(form);
+
(void) menv;
- return list(if_s, second(form), nil, cons(progn_s, rest(rest(form))), nao);
+
+ return list(if_s, test, nil, maybe_progn(body), nao);
}
static val me_while(val form, val menv)