summaryrefslogtreecommitdiffstats
path: root/eval.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2014-10-31 07:17:20 -0700
committerKaz Kylheku <kaz@kylheku.com>2014-10-31 07:17:20 -0700
commite313ceee48d860d3ee9591298c9ac1630096610b (patch)
tree0dc09b716d4e84be264824417c44f95c2daf45b7 /eval.c
parent484dd64d138a1ae977af05193036d3fe46220b2c (diff)
downloadtxr-e313ceee48d860d3ee9591298c9ac1630096610b.tar.gz
txr-e313ceee48d860d3ee9591298c9ac1630096610b.tar.bz2
txr-e313ceee48d860d3ee9591298c9ac1630096610b.zip
New macros tb and tc.
* eval.c (me_tb, me_tc): New static functions. (eval_init): Registered tb and tc macros. * txr.1: Documented tb and tc.
Diffstat (limited to 'eval.c')
-rw-r--r--eval.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/eval.c b/eval.c
index 7d92d22a..aab5a683 100644
--- a/eval.c
+++ b/eval.c
@@ -2595,6 +2595,34 @@ static val me_case(val form, val menv)
cons(cond_s, condpairs), nao);
}
+static val me_tb(val form, val menv)
+{
+ val opsym = pop(&form);
+ val pat = pop(&form);
+ val body = form;
+ val args = gensym(lit("args-"));
+
+ (void) opsym;
+ (void) menv;
+
+ return list(lambda_s, args,
+ cons(tree_bind_s, cons(pat, cons(args, body))), nao);
+}
+
+static val me_tc(val form, val menv)
+{
+ val opsym = pop(&form);
+ val cases = form;
+ val args = gensym(lit("args-"));
+
+ (void) opsym;
+ (void) menv;
+
+ return list(lambda_s, args,
+ cons(tree_case_s, cons(args, cases)), nao);
+}
+
+
static val expand_catch_clause(val form, val menv)
{
val sym = first(form);
@@ -3506,6 +3534,8 @@ void eval_init(void)
reg_mac(caseq_s, me_case);
reg_mac(caseql_s, me_case);
reg_mac(casequal_s, me_case);
+ reg_mac(intern(lit("tb"), user_package), me_tb);
+ reg_mac(intern(lit("tc"), user_package), me_tc);
reg_fun(cons_s, func_n2(cons));
reg_fun(intern(lit("make-lazy-cons"), user_package), func_n1(make_lazy_cons));