Brendan Eich brendan at mozilla.org
Thu Aug 21 09:27:55 PDT 2008

On Aug 21, 2008, at 8:21 AM, Peter Michaux wrote:

> I think that the let statement
> let (x = 2, y = x) {
>   print(y);
> }
> should desugar to exactly
> (function(x, y) {
>   print(y);
> })(2, x)

We've been over this. What if you replace print(y) with return y?

I had slides in 2006 talks on ES4 that showed how folks use closures  
for everything, including scoped statements and scoped expressions.  
That does not mean everything should desugar to function applications.

Besides the return issue, there are break and continue to consider,  
and the arguments object.

Desugaring may seem all the rage from the Harmony classes as sugar  
discussion, but it is not the only or best way, and it bites back. We  
do not want to overspecify so that the abstraction leaks and you can  
see the mutable, argument-ful, expensive functions under the hood.

> Also the let expression
> z = let (x = 2, y = x) x + y;
> should desugar to exactly
> z = (function(x, y) x + y)(2, x);
> The reasons for these particular desugarings is this is exactly what
> JavaScript programmers are writing today.

So what? Programmers do what they must in a language that has not  
evolved in nine years.

I cited Stockholm Syndrome the other day. It's a problem in JS-land.  
Users happy with closures for everything should go on using them.  
These are not the self-appointed victims I mean. But to say that let  
and block scope (and possibly other binding facilities not  
desugarable to ES1-3.x) must be spelled out exactly this way is  
bogus. Besides the leaks and inefficiencies, it makes a virtue of  
necessity, or of a vice.


More information about the Es-discuss mailing list