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/docwhat Dec 23 '11

re: exporting global objects to 'window' -- Maybe there should be a global keyword that "does the right thing"? I thought it'd be nice to make that explicit....

1

u/jashkenas Dec 23 '11

Yes, it would be awfully nice to make it explicit -- but unfortunately it's unspecified by JavaScript, and so different engines work in different ways. In the browser, you want to export your API to the "window", but not if you're using RequireJS, and not if you're on the server, in which case you want to use the "exports" object.

These things all behave in meaningfully different ways, so it's not something we can paper over.