Closures and let blocks

Brendan Eich brendan at
Thu Jan 3 12:51:08 PST 2008

On Jan 3, 2008, at 11:41 AM, Igor Bukanov wrote:

> So one way or another the symmetry is broken meaning an extra
> complexity for the implementations and extra rules for a user to
> learn.

This asymmetry exists with let declarations vs. blocks/expressions:

// outer x may be bound here

   ...            // but cannot be used here
   let x = f(x);  // or here as the argument to f
                  // x's default value is used instead


let (x = f(x)) { // x in f(x) finds outer x binding
   ...            // here x is in scope throughout the
                  // block (or expression if let expr)

This discussion brings the existing asymmetry to light, magnifies it  
via function's body, with its own scope(s). I'm not saying we should  
add (let (function f()...) ...) etc. just because of the existing,  
intentional asymmetry. But more asymmetry of the same kind is not  
obviously fatal either.

The case for (let (const C ...) ...) seems stronger in any event.


More information about the Es4-discuss mailing list