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

2

u/munificent Dec 23 '11

Do you think this change would be a good one for CoffeeScript to make?

Personally, I definitely do. Referencing an undefined name is going to throw an exception at runtime, so I'd rather find that error earlier when I can. Does CoffeeScript generally try to find "lint"-like errors like that and report them at compile time?

I think many people are disappointed you're not bringing them to JavaScript (JS.next) instead.

Well, those aren't mutually exclusive. :)

JS.next does fix most of these with let and getting rid of the global object, which is awesome. I don't think it will be able to fix closing over loop variables, at least not with C-style loops since that would break backwards compatibility, but I could be wrong.

We're still doing work on Traceur (and by "we" I mean Google in general, not me) which is cool. With that, you'll be able to try out Harmony features without having to wait for a Harmony-supporting native JS engine. It's not like Google's betting the entire farm on Dart, just a couple of plots of land.

Of course, there's also plenty that Dart does beyond just fixing lexical scoping that you really couldn't do in the context of JS. For example, we can catch most name errors on methods at compile time too (i.e. foo.typo) which you'll pretty much never be able to do with JS as far as I can tell.