From b76485e540762c60ba34dc36875c3b936f4df7b8 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Sun, 16 Feb 2014 16:26:31 -0800 Subject: * 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. --- ChangeLog | 9 +++++++++ eval.c | 13 +++++-------- txr.1 | 11 ++++++++--- 3 files changed, 22 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index 83be43f8..3ba822c1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2014-02-16 Kaz Kylheku + + * 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 New destructuring operators. 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 . If the object produced by matches , then the parameters are bound, becoming local variables, and the
-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 , 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 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 does not match the parameter list, then the usual exception is thrown; instead, processing continues -- cgit v1.2.3