r/coffeescript • • Jul 26 '13
Is CoffeeScript's Scoping Madness..? (x-post from /r/programming)
/r/programming/comments/1j1cw7/coffeescripts_scoping_is_madness/
6
Upvotes
r/coffeescript • • Jul 26 '13
View all comments
Show parent comment
2
u/BlitzTech Jul 27 '13
I know it's a bit late, but I'll try to answer your questions anyway:
configin your local function and actually that points to theconfigvariable you use in your whole module and suddenly assigning a value toconfig.doSomethingaffects everything in the module and not just the current function.varkeyword that forces a variable name to be local to the current function scope, regardless of where in that function thevarexpression is used (this is "hoisting"). Coffeescript intentionally did away with that because it's "ugly".In short, these kinds of issues don't often bite you, but when they do they are particularly insidious because the parts you observe to be buggy may be unrelated to the changes that caused them to break just because you chose poorly when picking variable names. I personally find the mental overhead of dealing with this and several other disambiguation issues to be more trouble than the gains in readability are worth.