summaryrefslogtreecommitdiffstats
path: root/eval.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2021-01-01 13:57:38 -0800
committerKaz Kylheku <kaz@kylheku.com>2021-01-01 13:57:38 -0800
commitdf9904609a72052b1014f48e4de8fa1baa74fc94 (patch)
tree4fd4f17d630ca6baaba4de89757c9de70db07174 /eval.c
parentf9f8b1cc48212450fd200cc517b8f9ed932e1cb9 (diff)
downloadtxr-df9904609a72052b1014f48e4de8fa1baa74fc94.tar.gz
txr-df9904609a72052b1014f48e4de8fa1baa74fc94.tar.bz2
txr-df9904609a72052b1014f48e4de8fa1baa74fc94.zip
progn, prog1, prog2: now also functions.
* eval.c (progn_fun, prog1_fun, prog2_fun): New static functions. (eval_init): Wire progn, prog1 and prog2 function bindings to new functions. * txr.1: Documented. * checkman.txr (check-func): Recognize Macro/function and Operators/functions heading.
Diffstat (limited to 'eval.c')
-rw-r--r--eval.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/eval.c b/eval.c
index 8b0cb0a3..dea5d1d8 100644
--- a/eval.c
+++ b/eval.c
@@ -6068,6 +6068,22 @@ static val and_fun(struct args *vals)
return item;
}
+static val progn_fun(struct args *vals)
+{
+ return if3(vals->list, car(lastcons(vals->list)), vals->arg[vals->fill - 1]);
+}
+
+static val prog1_fun(struct args *vals)
+{
+ return if2(args_more(vals, 0), args_at(vals, 0));
+}
+
+static val prog2_fun(struct args *vals)
+{
+ args_normalize_least(vals, 2);
+ return if2(vals->fill >= 2, vals->arg[1]);
+}
+
static val not_null(val obj)
{
return if3(nilp(obj), nil, t);
@@ -6738,6 +6754,9 @@ void eval_init(void)
reg_fun(if_s, func_n3o(if_fun, 2));
reg_fun(or_s, func_n0v(or_fun));
reg_fun(and_s, func_n0v(and_fun));
+ reg_fun(progn_s, func_n0v(progn_fun));
+ reg_fun(prog1_s, func_n0v(prog1_fun));
+ reg_fun(prog2_s, func_n0v(prog2_fun));
reg_fun(intern(lit("retf"), user_package), func_n1(retf));
reg_fun(intern(lit("apf"), user_package), func_n1v(apf));
reg_fun(intern(lit("ipf"), user_package), func_n1v(ipf));