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
0
u/showellshowell Dec 23 '11
Yep, I understand the pitfall, but user is a good example of a variable that probably works fine at top-level scope, since most functions in a business-domain CS file probably have the same concept of "user", and you would truly intend for it to have top-level scope.
I concede that even the best programmers do things by "accident" occasionally, but we mostly do things intentionally or stupidly. If you introduce "user" at top level scope, you're probably doing it for a reason--most of your functions have the same concept of user, so there's no reason not to make it top level. If you're introducing a variable at top-level scope for stupid reasons--laziness, sloppiness, whatever--then it would be nice if the language prevented you from shooting yourself in the foot, but let's be real about who's actually pulling the trigger.