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

What does DOTIMES mean?

    Date: 18 Nov 89  2121 PST
    From: Dick Gabriel <RPG@SAIL.Stanford.EDU>

    I believe that the output of the following is unspecified, am I wrong?

    (dolist (x (let ((a nil)) (dotimes (i 10 a) (push #'(lambda () i) a))))
      (print (funcall x)))

    I believe it can print either of the following (crlf's left out):

    10 10 10 10 10 10 10 10 10 10
    9 8 7 6 5 4 3 2 1 0

I think what's unspecified is not so loose as to allow anything at all
to be output!  I agree that it's unspecified whether the dotimes makes a
new binding of i on each iteration, or makes one binding and setq's it
on each iteration.  It's probably also allowed to use a mixture,
sometimes making a new binding and sometimes setq'ing an existing
binding (an unrolled loop might do that).

I think it must be unspecified in CLtL, or CLtL pp.88-9 would not have
gone to such effort to talk around it without saying anything about it.
This is repeated on pp.4-26 and 4-27 of the most recently mailed out draft.

I looked for cleanup issues about this and didn't find any.

This applies to most of the other iteration functions as well, although DO
and LOOP are explicitly specified to bind in certain places and setq in the