summaryrefslogtreecommitdiffstats
path: root/eval.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2014-12-23 09:17:27 -0800
committerKaz Kylheku <kaz@kylheku.com>2014-12-23 09:17:27 -0800
commitcbdbb602b8b821e2d353ad29e7d91796e87ef556 (patch)
tree31c4c981276e350af2e5c498e71542ab5d0a0e3b /eval.c
parente68f3828d79d16d2afc929c83d499e8e2e0dd38a (diff)
downloadtxr-cbdbb602b8b821e2d353ad29e7d91796e87ef556.tar.gz
txr-cbdbb602b8b821e2d353ad29e7d91796e87ef556.tar.bz2
txr-cbdbb602b8b821e2d353ad29e7d91796e87ef556.zip
* eval.c (ap_s, ret_s, aret_s): New symbol variables.
(me_ret): Static function renamed to me_ret_aret. Handles ret and aret macro expansion. (eval_init): Initialize ap_s, ret_s and aret_s. Re-register ret macro using ret_s and bind to me_ret_aret. Register aret macro. * txr.1: Documented aret. * tl.vim, txr.vim: Regenerated.
Diffstat (limited to 'eval.c')
-rw-r--r--eval.c20
1 files changed, 13 insertions, 7 deletions
diff --git a/eval.c b/eval.c
index 1c020c83..71f2470e 100644
--- a/eval.c
+++ b/eval.c
@@ -76,7 +76,8 @@ val dohash_s;
val uw_protect_s, return_s, return_from_s;
val list_s, append_s, apply_s, iapply_s;
val gen_s, gun_s, generate_s, rest_s, plus_s;
-val promise_s, op_s, identity_s, apf_s, ipf_s;
+val promise_s, op_s, ap_s, identity_s, apf_s, ipf_s;
+val ret_s, aret_s;
val hash_lit_s, hash_construct_s;
val vector_lit_s, vector_list_s;
val macro_time_s, with_saved_vars_s, macrolet_s;
@@ -2523,11 +2524,12 @@ static val me_ido(val form, val menv)
return list(ipf_s, cons(do_s, rest(form)), nao);
}
-static val me_ret(val form, val menv)
+static val me_ret_aret(val form, val menv)
{
- return list(op_s, identity_s, cons(progn_s,
- cons(list(var_s, rest_s, nao),
- rest(form))), nao);
+ val sym = if3(eq(car(form), ret_s), op_s, ap_s);
+ return list(sym, identity_s, cons(progn_s,
+ cons(list(var_s, rest_s, nao),
+ rest(form))), nao);
}
static val me_flet_labels(val form, val menv)
@@ -3476,9 +3478,12 @@ void eval_init(void)
generate_s = intern(lit("generate"), user_package);
promise_s = intern(lit("promise"), system_package);
op_s = intern(lit("op"), user_package);
+ ap_s = intern(lit("ap"), user_package);
do_s = intern(lit("do"), user_package);
apf_s = intern(lit("apf"), user_package);
ipf_s = intern(lit("ipf"), user_package);
+ ret_s = intern(lit("ret"), user_package);
+ aret_s = intern(lit("aret"), user_package);
identity_s = intern(lit("identity"), user_package);
rest_s = intern(lit("rest"), user_package);
hash_lit_s = intern(lit("hash-construct"), system_package);
@@ -3553,11 +3558,12 @@ void eval_init(void)
reg_mac(intern(lit("delay"), user_package), me_delay);
reg_mac(op_s, me_op);
reg_mac(do_s, me_op);
- reg_mac(intern(lit("ap"), user_package), me_ap);
+ reg_mac(ap_s, me_ap);
reg_mac(intern(lit("ip"), user_package), me_ip);
reg_mac(intern(lit("ado"), user_package), me_ado);
reg_mac(intern(lit("ido"), user_package), me_ido);
- reg_mac(intern(lit("ret"), user_package), me_ret);
+ reg_mac(ret_s, me_ret_aret);
+ reg_mac(aret_s, me_ret_aret);
reg_mac(qquote_s, me_qquote);
reg_mac(sys_qquote_s, me_qquote);
reg_mac(intern(lit("pprof"), user_package), me_pprof);