r/programming • • Dec 22 '11

The Problem with Implicit Scoping in CoffeeScript

http://lucumr.pocoo.org/2011/12/22/implicit-scoping-in-coffeescript/
83 Upvotes

116 comments sorted by

View all comments

Show parent comment

1

u/showellshowell Dec 23 '11

I didn't mean to imply that anybody was suggesting we go back to JavaScript's way of doing things.

The suggestions that I've heard would require special syntax to make this program print 100. Am I correct about that?

x = 0
f = ->
  x = 100
f()
console.log x # 100

3

u/LaurieCheers Dec 23 '11 edited Dec 23 '11

Yes - your lines x = 0 and x = 100 are doing two different operations, so there should be some kind of syntactic difference between them.

Otherwise, there is a potential for subtle bugs, and some day, some poor schlub will curse your name as they try to figure out what broke their program.