Revenge of the double-curly [Was: return when desugaring to closures]

David-Sarah Hopwood david.hopwood at industrial-designers.co.uk
Sat Oct 11 07:25:18 PDT 2008


Brendan Eich wrote:
> On Oct 10, 2008, at 11:58 AM, P T Withington wrote:
> 
>> ?  If so, perhaps you can see how I might imagine that:
>>
>>   function foo () {{
>>     var bar = ...;
>>   }}
>>
>> might be sugar for:
>>
>>   function foo () {
>>     let bar = ...;
>>   }
> 
> Nope, not compatible and not what I meant.

It is correct to say, though, that:

  function foo() {
    ...
    { var bar = baz; }
    ...
  }

is equivalent to

  function foo() {
    let bar = undefined;
    ...
    { bar = baz; }
    ...
  }

That is, 'var' need not be primitive. Only 'let' needs to be primitive.

Similarly, if we are careful in specifying 'lambda' then 'function' need
not be primitive, since it will be expressible as a rewrite to 'lambda'.

-- 
David-Sarah Hopwood


More information about the Es-discuss mailing list