[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Jim Meehan Comments

Jim Meehan asked me to forward a remark he was unable to successfully
mail to Common-Lisp.

ps. Oh yeah, by the way, here it is:

Date: Thu, 18 Sep 86 13:24:42 edt
From: James R. Meehan <csi!meehan@UUCP>
To: common-lisp@su-ai.arpa
Subject: Ignoring the DOTIMES variable

CLtL doesn't say whether DOTIMES actually "uses" the loop-variable, as
opposed to its value, and this ambiguity causes problems with portable
code.  If DOTIMES does use the loop-variable, then


can cause the compiler to issue a warning, but if DOTIMES doesn't use
the loop-variable, then

  (DOTIMES (I 10) (FOO)) 

can also cause the compiler to issue a warning.

Personally, I think DOTIMES shouldn't use the variable, so that


would be the correct style. That is, it should behave as if it were
implemented this way, more or less:

      `(DO ((,I 0 (1+ ,I))
            (,STOP ,END))
           ((>= ,I ,STOP) (LET ((,VAR ,I)) ,FINAL))
         (LET ((,VAR ,I)) ,@BODY))))

[This may need some additional work for copying declarations in the
"final" code, via the proposed PARSE-BODY or whatever.]

I've seen several implementations where DOTIMES actually uses the
loop-variable, thus permitting horrors like using SETQ to change the
value of the loop-variable and therefore control the iterations.  The
implementation above would prevent that.