Jeff Bezanson <[email protected]> wrote: > Yes, one could argue that a `for` loop variable should always be a new > variable, but that does make the constructs less orthogonal.
It's funny that you see this as less orthogonal, considering that, as Stefan pointed out, your "for" index will leak its final value. Consider for example embedding a for loop in a macro, and the risk for variable capture. Sounds pretty anti-orthogonal to me... > In any case I don't see how this is "do or don't, it depends". Depends > on what? Is the i in for(i=1:3) local to the loop? It depends (on whether there is an outer i or not). Does assignment create a binding? It depends (on the construct you're in). E.g. julia> if true; k = 10 end # -> 10 julia> k # -> 10 julia> let; l = 10 end # -> 10 julia> l # -> ERROR: UndefVarError: l not defined Does assignment in a function create a local binding? It depends (on whether the function is nested). etc. -- ELS'16 registration open! http://www.european-lisp-symposium.org Lisp, Jazz, Aïkido: http://www.didierverna.info
