Closures and let blocks

Brendan Eich brendan at mozilla.org
Thu Jan 3 09:44:43 PST 2008


On Jan 3, 2008, at 9:36 AM, Igor Bukanov wrote:

> On 03/01/2008, Brendan Eich <brendan at mozilla.org> wrote:
>>> let (f = function() { ...  f() ... }) { ... }
>>
>> The call to f within itself always refers to itself.
>
> I do not see how ES3 is relevant to this second case.

Oops, sorry -- pre-caffeine here. I misread that lambda as a named  
function expression. But it's anonymous, and its scope chain (as  
noted) starts with the let's outer scope, so it won't find itself  
bound to the name f.

> So I would like to clarify if in
>
> function f() { }
>
> let (f = function() { ...  f() ... }) { ... }
>
> f() should refer to the outer f or let-bound f.

Outer, no question.

> I thought that function definitions in the let blocks like in let
> (function f()) { } is supported for uniformity with let declarations
> that allow a usage like:
>
> let function f() { };

I missed that if so -- did you see this in the wiki, a trac ticket,  
or another doc?

/be




More information about the Es4-discuss mailing list