klisp

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

commit c83d9154e97121a98b54c5b5f20414d7b5a3f103
parent 11ae670fa7ce048c49d9dd1ed1a71689b665b2d5
Author: Andres Navarro <canavarro82@gmail.com>
Date:   Fri, 11 Mar 2011 21:10:36 -0300

Added $lambda to the ground environment.

Diffstat:
Msrc/kground.c | 22++++++++++++++++++++++
1 file changed, 22 insertions(+), 0 deletions(-)

diff --git a/src/kground.c b/src/kground.c @@ -1042,6 +1042,25 @@ void Svau(klisp_State *K, TValue *xparams, TValue ptree, TValue denv) kapply_cc(K, new_op); } +/* +** 5.?? Combiners +*/ + +void Slambda(klisp_State *K, TValue *xparams, TValue ptree, TValue denv) +{ + (void) xparams; + bind_al2p(K, "$lambda", ptree, vptree, vpenv, vbody); + + /* The ptree & body are copied to avoid mutation */ + vptree = check_copy_ptree(K, "$lambda", vptree, vpenv); + /* the body should be a list */ + (void)check_list(K, "$lambda", vbody); + vbody = copy_es_immutable_h(K, "$lambda", vbody); + + TValue new_app = make_applicative(K, do_vau, 4, vptree, vpenv, vbody, denv); + kapply_cc(K, new_app); +} + /* the ramaining list can't be null, that case is managed before */ void do_seq(klisp_State *K, TValue *xparams, TValue obj) { @@ -1255,5 +1274,8 @@ TValue kmake_ground_env(klisp_State *K) /* 4.10.5 unwrap */ add_applicative(K, ground_env, "unwrap", unwrap, 0); + /* 5.?? $lambda */ + add_operative(K, ground_env, "$lambda", Slambda, 0); + return ground_env; }