Ingvar von Schoultz ingvar-v-s at comhem.se
Mon Aug 25 15:00:31 PDT 2008

Brendan Eich wrote:
> The language may not support too many binding forms. The TC39 committee 
> probably won't. Both let and const as block-scoped bindings in the style 
> of var (but with use before set of a const illegal, and with const 
> having a mandatory initialiser even though it saves implementations no 
> cost) seem supported by those who spoke up at the last meeting.

So to convert these vars into consts...

     if (Debugging)
     {   var DatabaseName = "TestDatabase";
         var DisplayCount = 5;
         ... Ten more ...
     {   var DatabaseName = "RealDatabase";
         var DisplayCount = 15;
         ... Ten more ...

...we'll have to write something like this?

     {   DatabaseName,
         ... Ten more ...
     } =
     Debugging ?
     {   DatabaseName: "TestDatabase",
         DisplayCount: 5,
         ... Ten more ...
     {   DatabaseName: "RealDatabase",
         DisplayCount: 15,
         ... Ten more ...

Very often conditionals aren't that simple. It'll get ugly. The
new awkwardness does makes sense in big projects, but only there.

> let 
> blocks and let expressions do not have solid support in TC39.

I have no opinion on whether let blocks and let expressions
are useful, but you could make them very cheap by dropping the
intricacies that make let(x=x){} refer to two different x'es:

     let (a = x) {...} desugars to {let a = x; ...}

     let (a = x) a; desugars to {let a = x; a;}

As a bonus everyone will rejoice at the lessened cognitive burden
of intricacies.

Of course Schemers will find a let with these semantics confusing.
Clearly it needs a different name. How about... "local"? :-D

Ingvar von Schoultz

More information about the Es-discuss mailing list