return when desugaring to closures

Peter Michaux petermichaux at gmail.com
Sat Oct 11 19:06:39 PDT 2008


On Sat, Oct 11, 2008 at 3:16 PM, Brendan Eich <brendan at mozilla.com> wrote:

> The reason people like let blocks and expressions as opposed to let
> declarations, from what I can tell, is precisely the lack of hoisting to top
> of block done for let declarations, and the  greater clarity of head-scoped
> initialization (possibly using outer names that will be shadowed in the
> block or expression, but usually not) of the 'let (head) ...' syntax.
>
> Of course everything could be lambda-coded, but that's not harmonious or
> usable. Just let as new var is agreed upon, and let blocks and expressions
> could be let coded if there is no name shadowing (else they'd need
> lambda-coding). But we should not dismiss the use-cases for let
> blocks/expressions out of hand. There is experience in JS1.7 and 1.8 to
> consider here, not just hypothetical arguments about how often hand-written
> cases come up.

I agree with all of the above. The clarity of the let expressions and
blocks is valuable for understanding code as the hoisting issue is
gone and it is explicitly clear what is going on with variable scopes.

Peter


More information about the Es-discuss mailing list