Dear developers,

the following example shows that iter initializes
sequence variables twice, once with 0 and once with
the start of the range minus 1.

(macroexpand-1 '(iter (for i below 10)
                    (print i)))
-->
(LET* ((I 0))
 (DECLARE (TYPE NUMBER I))
 (BLOCK NIL
   (TAGBODY
     (SETQ I -1)
    LOOP-TOP-NIL
     (SETQ I (+ I 1))
     (IF (>= I 10) (GO LOOP-END-NIL))
     (PRINT I)
     (GO LOOP-TOP-NIL)
    LOOP-END-NIL)
   NIL))

The problem with this is not that this is a little bit
ugly but that one must allow negative values in declarations
for the driver variable, which conflicts with (unsigned-byte 32)
declarations.

Could I write a new driver instead of for that fixes the
problem or will I run into trouble because someteimes one of the
initial values is needed for something else (the else clause,
first-time-p or initially?).

Moreover, the declaration is not very tight. dotimes does better
on SBCL:

(macroexpand-1 '(dotimes (i 10)
                    (print i)))
-->
(DO ((I 0 (1+ I)))
   ((>= I 10) NIL)
   (DECLARE (TYPE UNSIGNED-BYTE I))
   (PRINT I))

Best regards
 Bruno Daniel

_______________________________________________
iterate-devel site list
iterate-devel@common-lisp.net
http://common-lisp.net/mailman/listinfo/iterate-devel

Reply via email to