klisp

an open source interpreter for the Kernel Programming Language.
git clone http://git.hanabi.in/repos/klisp.git
Log | Files | Refs | README

commit eb5be949efeda606d06702034f6bccbebe55772b
parent 477ec83a948dc7fd495b6be0ef6b33e15be079fb
Author: Andres Navarro <canavarro82@gmail.com>
Date:   Thu, 31 Mar 2011 16:05:02 -0300

Added bool_check flag to the continuations created by $if and $cond. These are not necessary for tail context bool checking in $and? & $or? but save one continuation in some common use cases.

Diffstat:
Msrc/kgcontrol.c | 15++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/src/kgcontrol.c b/src/kgcontrol.c @@ -38,7 +38,11 @@ void Sif(klisp_State *K, TValue *xparams, TValue ptree, TValue denv) TValue new_cont = kmake_continuation(K, kget_cc(K), KNIL, KNIL, select_clause, 3, denv, cons_c, alt_c); - + /* + ** Mark as a bool checking cont, not necessary but avoids a continuation + ** in the last evaluation in the common use of ($if ($or?/$and? ...) ...) + */ + kset_bool_check_cont(new_cont); klispS_set_cc(K, new_cont); ktail_eval(K, test, denv); } @@ -218,6 +222,12 @@ void do_cond(klisp_State *K, TValue *xparams, TValue obj) kmake_continuation(K, kget_cc(K), KNIL, KNIL, do_cond, 4, kcar(bodies), kcdr(tests), kcdr(bodies), denv); + /* + ** Mark as a bool checking cont, not necessary but avoids a + ** continuation in the last evaluation in the common use of + ** ($cond ... (($or?/$and? ...) ...) ...) + */ + kset_bool_check_cont(new_cont); kset_cc(K, new_cont); ktail_eval(K, kcar(tests), denv); } @@ -241,6 +251,9 @@ void Scond(klisp_State *K, TValue *xparams, TValue ptree, TValue denv) TValue new_cont = kmake_continuation(K, kget_cc(K), KNIL, KNIL, do_cond, 4, KNIL, tests, bodies, denv); + /* there is no need to mark this continuation with bool check + because it is just a dummy, no evaluation happens in its + dynamic extent */ kset_cc(K, new_cont); obj = KFALSE; }