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

What does DOTIMES mean?



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

and maybe even this:

9 9 9 9 9 9 9 9 9 9

I think there are valid reasons for each of the first two (the third is like the
first). The first possibility is the straightforward implementation. The second
possibility makes slightly more sense for a parallel processing system, because
one can imagine writing this:

	(dotimes (i n) (spawn (f i))

If it takes a while for each process to get going, you might not get the
values of i you expect unless the dotimes copies the binding.

Opinions?

			-rpg-