summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2017-10-25 20:19:04 -0700
committerKaz Kylheku <kaz@kylheku.com>2017-10-25 20:19:04 -0700
commitfa404ca92f61ded69e431314cc39b04827e52a3d (patch)
tree0f5402ea189d3b3240fa76f602c9f7c0a14d1d05
parent26dad8b62deb2e32d9d13c9d0676079bee6f8fb6 (diff)
downloadtxr-fa404ca92f61ded69e431314cc39b04827e52a3d.tar.gz
txr-fa404ca92f61ded69e431314cc39b04827e52a3d.tar.bz2
txr-fa404ca92f61ded69e431314cc39b04827e52a3d.zip
caseq, caseql, casequal: improvement in expansion.
* eval.c (me_case): When a list of case keys is one element long, reduce it to an atom. Then a simple equality is applied whether the item is equal to the key, rather than whether it is a member of a list containing that one key. This helps with the (t) case which is mandatory, since t is ruled out as a key.
-rw-r--r--eval.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/eval.c b/eval.c
index 31938f56..3f904e21 100644
--- a/eval.c
+++ b/eval.c
@@ -3665,6 +3665,9 @@ static val me_case(val form, val menv)
if (keys == t)
eval_error(form_orig, lit("~s: symbol t used as key"), casesym, nao);
+ if (consp(keys) && !cdr(keys))
+ keys = car(keys);
+
if (star) {
if (atom(keys))
keys = eval(keys, nil, form);