For Loop Desugaring (was: return when desugaring to closures)

Brendan Eich brendan at
Tue Oct 14 13:52:12 PDT 2008

On Oct 14, 2008, at 1:36 PM, Brendan Eich wrote:

> On Oct 14, 2008, at 12:39 PM, Waldemar Horwat wrote:
>> What does lambda(x = y){...}(z) do when z is undefined?
> Passes undefined bound to x. Undefined is not the same as missing.

Lest anyone think otherwise, "missing" means actual argument count is  
less than number of formal parameters. It's not yet another undefined- 
like value code.

The implementation knows that lambda has arity 1 with a default  
parameter value. It knows the call passes an actual (that its value is  
undefined does not matter). So the default parameter value is not used.

Default parameters are evaluated once when the lambda expression is  
evaluated. That the lambda is immediately applied in your questions'  
examples may make this point unclear. This is why my answer to your  

> lambda(x = y){...}() mean?  Is it different from
> lambda(x){...}(y)

was "No." But if you captured the lambda and applied it elsewhere to a  
different y (y in a different scope chain), this equivalence would not  
hold. Hope this is all non-controversial (modulo blunders on my part  
explaining it).

-------------- next part --------------
An HTML attachment was scrubbed...

More information about the Es-discuss mailing list