jashkenas/coffee-script — Issue #1774: Generate wrapper only when needed
Author: TrevorBurnham
Created: 2011-10-17 01:25:44+00:00
State: open

Lately, Google Dart has been getting some well-deserved flack for a trivial "Hello, world" example generating thousands of lines of JS output. Meanwhile, though, CoffeeScript is generating 3 lines when it could be generating just 1. Since

console.log 'Hello, world!'

contains no scoped variables, I don't see any benefit to generating the output

(function() {
console.log('Hello, world!');
}).call(this);

instead of just

console.log('Hello, world!');

I propose that the wrapper only be added when it has an effect on scope. What do other folks think?