Closures and let blocks

Lars Hansen lhansen at adobe.com
Thu Jan 3 09:53:44 PST 2008


> -----Original Message-----
> From: es4-discuss-bounces at mozilla.org 
> [mailto:es4-discuss-bounces at mozilla.org] On Behalf Of Brendan Eich
> Sent: 3. januar 2008 18:45
> To: Igor Bukanov
> Cc: es4-discuss at mozilla.org
> Subject: Re: Closures and let blocks
> 
> 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?

Ditto -- news to me if "let (function f() ...) ..." has a meaning.  The
analogy of "let function" is to "let const" and plain let-is-the-new-var
"let".  I don't recall having a "let (const x...) ..." form either.

--lars

> 
> /be
> 
> _______________________________________________
> Es4-discuss mailing list
> Es4-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es4-discuss
> 



More information about the Es4-discuss mailing list