Re:CoffeeScript, a little language that compiles to JavaScri...
by jashkenas on Thursday December 24, 2009 @08:50PM
(#1014667)
Alright -- this is fixed with the latest commit. I've enhanced the --no-wrap option to not emit "var" declarations at the top level. If you don't want the safety wrapper, then you probably intend to make them global in any case.
bin/cs now works like a charm. I might pull it back into the main bin/coffee-script executable. Start a REPL if run without arguments ... --run for executing CoffeeScripts via Narwhal... something like that.
Re:CoffeeScript, a little language that compiles to JavaScri...
by tlrobinson on Friday December 25, 2009 @03:18AM
(#1014858)
On second thought, ideally these should be different options. When used in a module we add our own function wrapper but still want the "var"s. In the REPL we don't want the "var"s (making the safety wrapper useless, but harmless)
Re:CoffeeScript, a little language that compiles to JavaScri...
by tlrobinson on Thursday December 24, 2009 @10:39PM
(#1014731)
Great, thanks.
The other problem with the REPL is that all variable assignments are prefixed with "var", so they're always local to the function where the eval-ing is done, thus it's impossible to get variables to persist between REPL commands (without explicitly assigning to a property of "global").
One solution would be to add a flag that disables the "var" for top level assignments (but not within functions).
Alternatively, I think I could do some engine-specific black magic (__proto__ hacks), at least for Rhino.