r/programming • u/zumpiez • Dec 22 '11
The Problem with Implicit Scoping in CoffeeScript
http://lucumr.pocoo.org/2011/12/22/implicit-scoping-in-coffeescript/
83
Upvotes
r/programming • u/zumpiez • Dec 22 '11
View all comments
Show parent comment
2
u/dobryak Dec 23 '11
Did you mean, "why do we need to distinguish the two"?
Personally, I find the standard* lexical scope intuitive and practical since I am very used to it. What CS proposes is a change that I find untested and unneeded (hey, we have been using standard lexical scope, with binding and assignment clearly separated, for 50 years or so!).
I haven't thought about the possible consequences of mixing up assignment and binding -- but it still makes me wary since I've seen so many PLs and DSLs which only bring unnecessary pain and suffering to their users because of random quirks like this one (i.e., unclear rules for lexical scope mixed in a strange way with assignment).
Where a standard interpreter evaluates "var x;" and "x = 5" differently (the first one adds mutable variable to the environment, the second one looks up a variable in the environment, and either fails or assigns 5 to an existing variable), a language like CS will have to decide what the programmer meant.
This is, however, not at all the issue I wanted to talk about; to recall, I said the aforementioned distinction is not complex to me (from a standpoint of day-to-day programming). Now the question is, what does it buy us? As I see it, we have one keyword less ("var"), and well, basically, that's it. So, is this worth it?