summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2014-02-16 16:26:31 -0800
committerKaz Kylheku <kaz@kylheku.com>2014-02-16 16:26:31 -0800
commitb76485e540762c60ba34dc36875c3b936f4df7b8 (patch)
tree04f04f42e09bd11eaa3911840dc702a757b2308b
parent5cb820d7f9be3df23e19fd67a2f5ff6309188eea (diff)
downloadtxr-b76485e540762c60ba34dc36875c3b936f4df7b8.tar.gz
txr-b76485e540762c60ba34dc36875c3b936f4df7b8.tar.bz2
txr-b76485e540762c60ba34dc36875c3b936f4df7b8.zip
* eval.c (op_tree_case): Removed superfluous handling of
nil parameter list; this is correctly handled by bind_macro_params. Added support for the colon symbol as an indication that the case is declined. * txr.1: Updated.
-rw-r--r--ChangeLog9
-rw-r--r--eval.c13
-rw-r--r--txr.111
3 files changed, 22 insertions, 11 deletions
diff --git a/ChangeLog b/ChangeLog
index 83be43f8..3ba822c1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,14 @@
2014-02-16 Kaz Kylheku <kaz@kylheku.com>
+ * eval.c (op_tree_case): Removed superfluous handling of
+ nil parameter list; this is correctly handled by bind_macro_params.
+ Added support for the colon symbol as an indication that
+ the case is declined.
+
+ * txr.1: Updated.
+
+2014-02-16 Kaz Kylheku <kaz@kylheku.com>
+
New destructuring operators.
* eval.c (tree_case_s, tree_bind_s): New symbol variables.
diff --git a/eval.c b/eval.c
index e7ad031d..54e7024e 100644
--- a/eval.c
+++ b/eval.c
@@ -1107,15 +1107,12 @@ static val op_tree_case(val form, val env)
for (; consp(cases); cases = cdr(cases)) {
val onecase = car(cases);
cons_bind (params, forms, onecase);
-
- if (!params) {
- if (!expr_val)
- return eval_progn(forms, env, forms);
- } else {
- val new_env = bind_macro_params(env, nil, params, expr_val,
+ val new_env = bind_macro_params(env, nil, params, expr_val,
colon_k, onecase);
- if (new_env)
- return eval_progn(forms, new_env, forms);
+ if (new_env) {
+ val ret = eval_progn(forms, new_env, forms);
+ if (ret != colon_k)
+ return ret;
}
}
diff --git a/txr.1 b/txr.1
index d47af3a8..2ccb8338 100644
--- a/txr.1
+++ b/txr.1
@@ -12689,9 +12689,14 @@ style parameter list <macro-style-params>.
If the object produced by <expr> matches <macro-style-params>, then the
parameters are bound, becoming local variables, and the <form>-s, if any, are
-evaluated in order in the environment in which those variables are visible. The
-evaluation of tree-case then ends, returning the value of the last <form>, or
-else nil if there are no forms.
+evaluated in order in the environment in which those variables are visible.
+
+If there are forms, the value of the last <form> becomes the result value of
+the case, otherwise the result value of the case is nil.
+
+If the result value of a case is the object : (the colon symbol), then
+processing continues with the next case. Otherwise the evaluation of tree-case
+terminates, returning the result value.
If the value of <expr> does not match the <macro-style-params> parameter
list, then the usual exception is thrown; instead, processing continues