summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2016-11-11 22:08:33 -0800
committerKaz Kylheku <kaz@kylheku.com>2016-11-11 22:08:33 -0800
commit37c881d461e55d5c5115c6c6ed397a3df8913fd2 (patch)
treecd944b1df641c86eea458a14c1d9ab9508a9425d
parent926ad2e614f5c4c817e3ed8b560ded9045a7ccba (diff)
downloadtxr-37c881d461e55d5c5115c6c6ed397a3df8913fd2.tar.gz
txr-37c881d461e55d5c5115c6c6ed397a3df8913fd2.tar.bz2
txr-37c881d461e55d5c5115c6c6ed397a3df8913fd2.zip
Clause in case{q,ql,qual} with no forms yields nil.
* eval.c (me_case): If forms is nil, substitute the object (nil) for forms, to ensure a nil result through the expansion to a cond. * txr.1: Documented and added compat notes.
-rw-r--r--eval.c4
-rw-r--r--txr.122
2 files changed, 21 insertions, 5 deletions
diff --git a/eval.c b/eval.c
index f863e5fd..e0c852b0 100644
--- a/eval.c
+++ b/eval.c
@@ -3132,6 +3132,7 @@ static val me_case(val form, val menv)
val testform = pop(&form);
val tformsym = gensym(lit("test-"));
val memfuncsym, eqfuncsym;
+ val lofnil = cons(nil, nil);
list_collect_decl (condpairs, ptail);
if (casesym == caseq_s) {
@@ -3167,12 +3168,13 @@ static val me_case(val form, val menv)
nao),
forms));
} else {
+ uses_or2;
ptail = list_collect(ptail,
cons(list(if3(atom(keys), eqfuncsym, memfuncsym),
tformsym,
list(quote_s, keys, nao),
nao),
- forms));
+ or2(forms, lofnil)));
}
}
diff --git a/txr.1 b/txr.1
index 054cd670..a7831d2e 100644
--- a/txr.1
+++ b/txr.1
@@ -13178,6 +13178,9 @@ If all these clauses are exhausted, and there is no
then the value nil is returned. Otherwise, the forms in the
.meta else-clause
are evaluated, and the value of the last one is returned.
+If there are no forms, then
+.code nil
+is returned.
The syntax of a
.meta normal-clause
@@ -49313,13 +49316,15 @@ is given an argument which is equal or lower. For instance
.code "-C 103"
selects the behaviors described below for version 105, but not those for 102.
.IP 156
-After version 156, a bug was fixed in the macro expander for
+After version 156, two behaviors changed in the in the macro expander for
.codn caseq ,
.code caseql
and
-.codn casequal .
-Selecting a compatibility value of 156 or less restores the buggy
-behavior. The bug was that single-atom case keys were undergoing
+.codn casequal :
+one outright bug was fixed, and one hitherto undocumented behavior
+was changed and specified in the documentation at the same time.
+Selecting a compatibility value of 156 or less restores the previous
+behaviors. The bug was that single-atom case keys were undergoing
evaluation. For instance
.code "(caseql x (a 0))"
would arrange for the evaluation of
@@ -49330,6 +49335,15 @@ itself. Beside using the compatibility mechanism, a workaround is to
use a list of keys, exemplified by a rewrite of the foregoing
expression to
.codn "(caseql x ((a) 0))" .
+The other behavior was that empty lists of forms in a clause were
+producing a result value of
+.codn t .
+For example
+.code "(case 1 (1))"
+previously yielded
+.codn t ,
+but now yields
+.codn nil .
.IP 155
After version 155, the
.code tok-str