local

Jon Zeppieri jaz at bu.edu
Fri Aug 22 11:10:27 PDT 2008


On Fri, Aug 22, 2008 at 2:22 AM, Brendan Eich <brendan at mozilla.org> wrote:
> On Aug 21, 2008, at 10:10 PM, Breton Slivka wrote:
>
>> In the case of let statements, as I understand it, the current
>> proposal, and how let works in firefox is that
>>
>>  let (x = 2, y = x) {
>>  print(y);
>>  }
>>
>> "desugars" to
>>
>> {
>> let x = 2, y = x;
>> print(y);
>> }
>
> No, because in the latter, as for var in a program or function body,
> let x is hoisted to the top of the block, so y's initializer x is not
> the value of the outer x, but the undefined initial value of the
> hoisted inner x.
>
> So let statements really are different from let declarations in blocks.

I didn't know that JS 1.7 already implements different binding
semantics for let declarations on one hand and let statements and
expressions on the other.  That's odd.  I can see why you might want
different semantics, but using the same keyword in both cases is a bit
gross.

It might actually be better to add separate let and letrec keywords...
except that the meaning of let declarations (as opposed, I mean, to
letrec declarations) might be strange...

var x = 0;

{
  ...
  let x = 10;
  ...
  let y = x + 5;

}

printf


More information about the Es-discuss mailing list