return when desugaring to closures

Waldemar Horwat waldemar at google.com
Mon Oct 13 16:01:01 PDT 2008


Brendan Eich wrote:
> If using an uninitialized let binding is an error, then hoisting is  
> pointless except to make the statements between start of block and the  
> let declaration a dead zone for the binding name. This fits the  
> ancient, weak but not entirely worthless post-hoc rationale for var  
> hoisting (to avoid confusion among novice or inexperienced programmers  
> by making many scopes, each implicitly opened by var), but it's not  
> particularly useful.

This was our agreement from the ES4 days.  It's very useful, in that it allows mutually recursive lambdas.

> What's more, as discussed here and in TC39, repeated let declarations  
> for the same binding name within the same block should be allowed.  

You can't do that in ES-Harmony.  There is no way to tell if the two let declarations have the same type.  For orthogonality you'd also need to allow multiple const declarations within the same scope, and I just don't want to go there.

> Anything else is user- and refactoring-hostile. So the non-initial let  
> declarations for a given name in the same block would be ignored.

This is loaded language, but I can't tell how requiring there to be a unique point of definition for a const or let is user-hostile.

    Waldemar


More information about the Es-discuss mailing list