You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Yeah, this is consistent with JS behaviour. CS used to close over loop iterators when defining functions within the comprehension, but it lead to sometimes very complex compilations, and would be equally unexpected behaviour for someone expecting our current, more straightforward compilation. Recommended style is now:
comprehended = ((do (k = i) -> -> alert k) for i in [0..10])
or
comprehended = ((do (i) -> -> alert i) for i in [0..10])
or
comprehended = (((i) -> -> alert i)(i) for i in [0..10])
Oh, no question, lexical scope makes for less straightforward compilation, compared to dynamic scope; I just assumed that the scoping rules would be consistently lexical. Do you happen to remember where the commit to change that was? That might be interesting to see.
In the REPL on coffeescript.org:
This is unintuitive.
The text was updated successfully, but these errors were encountered: