summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog8
-rw-r--r--eval.c9
-rw-r--r--txr.116
3 files changed, 32 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index eef1fdd6..da3cb05a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2011-12-07 Kaz Kylheku <kaz@kylheku.com>
+
+ * eval.c (progn_s): New symbol variable.
+ (op_progn): New static function.
+ (eval_init): Initialize new variable, register progn operator.
+
+ * txr.1: progn documented.
+
2011-12-06 Kaz Kylheku <kaz@kylheku.com>
Version 046
diff --git a/eval.c b/eval.c
index f3abb911..40f0057d 100644
--- a/eval.c
+++ b/eval.c
@@ -50,7 +50,7 @@ val top_vb, top_fb;
val op_table;
val eval_error_s;
-val let_s, let_star_s, lambda_s, call_s;
+val progn_s, let_s, let_star_s, lambda_s, call_s;
val cond_s, if_s, and_s, or_s, defvar_s, defun_s;
val inc_s, dec_s, push_s, pop_s, gethash_s, car_s, cdr_s;
val for_s, for_star_s, dohash_s, uw_protect_s, return_s, return_from_s;
@@ -400,6 +400,11 @@ static val bindings_helper(val vars, val env, val sequential, val ctx_form)
return new_bindings;
}
+static val op_progn(val form, val env)
+{
+ return eval_progn(rest(form), env, form);
+}
+
static val op_let(val form, val env)
{
val let = first(form);
@@ -992,6 +997,7 @@ void eval_init(void)
top_vb = make_hash(t, nil, nil);
op_table = make_hash(nil, nil, nil);
+ progn_s = intern(lit("progn"), user_package);
let_s = intern(lit("let"), user_package);
let_star_s = intern(lit("let*"), user_package);
lambda_s = intern(lit("lambda"), user_package);
@@ -1025,6 +1031,7 @@ void eval_init(void)
sethash(op_table, qquote_s, cptr((mem_t *) op_qquote_error));
sethash(op_table, unquote_s, cptr((mem_t *) op_unquote_error));
sethash(op_table, splice_s, cptr((mem_t *) op_unquote_error));
+ sethash(op_table, progn_s, cptr((mem_t *) op_progn));
sethash(op_table, let_s, cptr((mem_t *) op_let));
sethash(op_table, let_star_s, cptr((mem_t *) op_let));
sethash(op_table, lambda_s, cptr((mem_t *) op_lambda));
diff --git a/txr.1 b/txr.1
index bab0f4c5..f4bc42d9 100644
--- a/txr.1
+++ b/txr.1
@@ -4322,6 +4322,22 @@ alternative1 | alternative2 | ... | alternativeN
Multiple syntactic variations allowed in one place are
indicated as bar-separated items.
+.SS Operator progn
+
+.TP
+Syntax:
+(progn <form>*)
+
+.TP
+Description
+
+The progn operator evaluates forms in order, and returns the value
+of the last form. The return value of (progn) is nil.
+
+Various other operators such as let also arrange for the evaluation
+of a body of forms, the value of the last of which is returned.
+These operators are said to feature an "implicit progn".
+
.SS Operators let and let*
.TP