Description
[post from Stefan regarding example below]
The key is that without a let the same i is captured by each closure, so the two closures actually do the same thing. With a let i, each iteration has a different i and the closures are thus different and each one when called will return the value of its own i, i.e. the corresponding iteration number. This is a very Lispy thing.
I have previously thought that it might be good if each iteration of a for loop implicitly had its own i, but that might adversely affect performance. I suspect, however, it would be easier to reason about, would possibly allow us to eliminate the let keyword, and might be more friendly to implicit parallelism since it breaks the dependency between different iterations.
[the example]
Does Julia intend that these two ways of assigning an anonymous function yield different results?
M=Array(Any,2)
for i in 1:2
M[i] = () -> i
end
while