Hi,
why are some forms restricted to top-level, while others are not?
For example, the following looks like a good replacement of FOR IN which is not restricted to top-level iteration:
(iter (repeat 5) (let () ; not at top-level (with l = '(1 2 3)) (for el do-next (if (null l) (terminate) (dsetq el (pop l)))) (princ (cons "hi" el)))) (hi . 1)(hi . 2)(hi . 3) This could be wrapped via iterate:defxyz and even be used as a generator.
Likewise, the in-whole-vector example in the manual IMHO provides a better iterator than the built-in IN-VECTOR: it is not restricted to top-level -- it uses FOR DO-NEXT.
(iterate(repeat 5)(let()(for x in-vector #(1 2 3))(princ x))) Iterate, in (FOR X IN-VECTOR #(1 2 3)): Clause can occur only at top-level [Condition of type SIMPLE-ERROR]
Does anybody know the reason of the top-level check? Is it a kind of user safeguard?
Should the meaning of "TOP-LEVEL" in Iterate be redefined?
Regards, Jörg Höhle.