summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2015-11-08 14:48:33 -0800
committerKaz Kylheku <kaz@kylheku.com>2015-11-08 14:48:33 -0800
commit84af229255b1e5a594a54907adc317b61828a989 (patch)
tree3de55e9e06b1ccaa586947ceca866c6444403b85
parent4d9a7fdc21730824f69d6e33e497dade864a170f (diff)
downloadtxr-84af229255b1e5a594a54907adc317b61828a989.tar.gz
txr-84af229255b1e5a594a54907adc317b61828a989.tar.bz2
txr-84af229255b1e5a594a54907adc317b61828a989.zip
Variable init forms of for go inside nil block.
* eval.c (op_for): Establish the block before doing any evaluation, subject to the compatibility option. * txr.1: Updated documentation for for, exchanging steps 1 and 2. Added compatibility notes.
-rw-r--r--eval.c10
-rw-r--r--txr.120
2 files changed, 21 insertions, 9 deletions
diff --git a/eval.c b/eval.c
index 6d7710b0..174dc79d 100644
--- a/eval.c
+++ b/eval.c
@@ -1811,11 +1811,15 @@ static val op_for(val form, val env)
val incs = fourth(form);
val forms = rest(rest(rest(rest(form))));
val new_env;
- val new_bindings = bindings_helper(vars, env, eq(forsym, for_star_s),
- &new_env, t, form);
+ int oldscope = opt_compat && opt_compat <= 123;
+
+ if (oldscope)
+ (void) bindings_helper(vars, env, eq(forsym, for_star_s), &new_env, t, form);
+
uw_block_begin (nil, result);
- (void) new_bindings;
+ if (!oldscope)
+ (void) bindings_helper(vars, env, eq(forsym, for_star_s), &new_env, t, form);
for (; cond == nil || eval(car(cond), new_env, form);
eval_progn(incs, new_env, form))
diff --git a/txr.1 b/txr.1
index b7e1b202..c2f25772 100644
--- a/txr.1
+++ b/txr.1
@@ -12502,6 +12502,11 @@ and
operators execute these steps:
.RS
.IP 1.
+Establish an anonymous block over the entire form, allowing
+the
+.code return
+operator to be used to terminate the loop.
+.IP 2.
Establish bindings for the specified variables similarly to
.code let
and
@@ -12514,11 +12519,6 @@ each
.meta inc-form
and each
.metn body-form .
-.IP 2.
-Establish an anonymous block over the remaining forms, allowing
-the
-.code return
-operator to be used to terminate the loop.
.IP 3.
Evaluate
.metn test-form .
@@ -37341,7 +37341,15 @@ of these version values, the described behaviors are provided if
is given an argument which is equal or lower. For instance
.code -C 103
selects the behaviors described below for version 105, but not those for 102.
-
+.IP 123
+In \*(TX 123 and earlier, the variable initialization forms of a
+.code for
+or
+.code for*
+loop were evaluated outside of the scope of the implicit
+.code nil
+block. They are now inside the block. The compatibility option will
+restore the old behavior.
.IP 121
In \*(TX 121 and earlier versions, \*(TL expressions evaluated in the
pattern language were placed in a lexical environment in which the