-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Does anyone know the rationale for the different treatment of the
control variable of:
(loop repeat 10
(do-something))
and other loops, and
(dotimes (i 10)
(do-something)
The "dotimes" one is declared as type INTEGER while the loop ones are
REAL.
USER(1): :ma (dotimes (i 10) (do-something))
(LET ((I 0))
(DECLARE (TYPE (INTEGER 0 10) I))
(BLOCK NIL
(TAGBODY
#:|Tag324| (COND ((>= I 10) (RETURN-FROM NIL (PROGN))))
(TAGBODY (DO-SOMETHING))
(PSETQ I (1+ I))
(GO #:|Tag324|))))
USER(2): :ma (loop for i from 0 below 10 do (do-something))
(LET ((I 0))
(DECLARE (TYPE REAL I))
(BLOCK NIL
(TAGBODY
EXCL::NEXT-LOOP (DO-SOMETHING)
(EXCL::LOOP-REALLY-DESETQ I (1+ I))
(WHEN (>= I '10) (GO EXCL::END-LOOP))
(GO EXCL::NEXT-LOOP)
EXCL::END-LOOP)))
USER(3): :ma (loop repeat 10 do (do-something))
(LET ((#:G2969 10))
(DECLARE (TYPE REAL #:G2969))
(BLOCK NIL
(TAGBODY
EXCL::NEXT-LOOP (DO-SOMETHING)
(WHEN (NOT (PLUSP (SETQ #:G2969 (1- #:G2969))))
(GO EXCL::END-LOOP))
(GO EXCL::NEXT-LOOP)
EXCL::END-LOOP)))
It is easy enough to do (loop for i of-type fixnum ...) or INTEGER or
whatever, but there's no way (to my knowledge) of doing the same with
the hidden "repeat" variable, and I hate being forced to declare a
visible name for it when I'm not interested in the loop counter, just
the number of iterations.
/L/e/k/t/u
-----BEGIN PGP SIGNATURE-----
Version: PGPfreeware 6.0.2i
iQA/AwUBNy21bP4C0a0jUw5YEQJVtwCcCCfgqORNXZB12IaLw1q/F7io98wAoJrb
VnmgKd/Ewop/qePGpsfqNkjl
=/LpI
-----END PGP SIGNATURE-----