diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2016-11-11 22:08:33 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2016-11-11 22:08:33 -0800 |
commit | 37c881d461e55d5c5115c6c6ed397a3df8913fd2 (patch) | |
tree | cd944b1df641c86eea458a14c1d9ab9508a9425d | |
parent | 926ad2e614f5c4c817e3ed8b560ded9045a7ccba (diff) | |
download | txr-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.c | 4 | ||||
-rw-r--r-- | txr.1 | 22 |
2 files changed, 21 insertions, 5 deletions
@@ -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))); } } @@ -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 |