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
30
u/jrochkind Dec 22 '11
That's not how I would describe the downside. I would say that the downside is that you can change the semantics of one block by making a change at a lexically much higher block. What had been a variable with scope purely at the local block became a variable with scope at a higher block, because of a change made at that lexically higher block.
So this actually sort of counters what you imply, that you only need local knowledge to understand what's going on. While it's true that "every place you see the variable "x" in a given lexical scope, you always know that it refers to the same thing," in fact it is non-trivial to figure out what that "thing" IS, you have to look at the entire lexical scope up to the root to figure it out, you can't figure it out only by looking at a local scope.
So I'm not sure I buy that this is a net reduction of conceptual complexity. In my mind, you reduce conceptual complexity by making the interpretation of a specific block possible only by looking at that block; requiring you to look up through all lexical containers is added complexity.