arrow function syntax simplified

Irakli Gozalishvili rfobic at gmail.com
Thu Mar 29 11:48:56 PDT 2012


Few questions on this new arrow functions:

let foo = x => x * x


1. What is foo.prototype ?  
2. What does new foo(y) does ?
3. Is there going to be equivalent of Function for arrow functions ?
4. Is Function.create(foo) going to work ?
5. Will foo.call, foo.apply pass in the `this` ?

Regards
--
Irakli Gozalishvili
Web: http://www.jeditoolkit.com/


On Thursday, 2012-03-29 at 07:15 , Brendan Eich wrote:

> This is all moot now -- see meeting notes and followups. Thin arrow is  
> not going to make it, we want one arrow. The |this| parameter for opting  
> into dynamic rather than default-lexical |this| also died. Method  
> definition shorthand covers the only strong use-case, as Kevin's  
> analysis shows.
>  
> /be
>  
> Herby Vojčík wrote:
> > Brendan Eich wrote:
> > > Kevin Smith wrote:
> > > >  
> > > > I hate the CoffeeScript deviation, though. It's just confusing for
> > > > anyone who ever learned that fat-arrow binds |this| and thin-arrow
> > > > doesn't.
> > > >  
> > > >  
> > > > True. On the other hand, "all arrows bind |this|" is also quite simple
> > > > and easy to remember.
> > > >  
> > >  
> > >  
> > > Yes, and I kept the part of the proposal that allows |this| as a leading
> > > arrow formal parameter, including with parameter default value. This
> > > suggests a slight variation on the strawman, per your suggestion:
> > >  
> > > x -> { return this.x; } // lexical this for thin arrow
> > > x => this.x // as for fat arrow
> > >  
> > > (this, x) -> { return this.x; } // dynamic this, five letter syn-tax
> > > (this, x) => this.x // ditto for the expression-body form
> > >  
> >  
> >  
> > I like this very much. Clear, orthogonal, readable.
> > It would be nice if this could get through.
> >  
> > > /be
> >  
> > Herby
> >  
> > P.S.: Dynamic this no-arg function could also use one-arg shorthand?
> >  
> > this => this.x
> > this -> { return this.x; }
> >  
>  
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org (mailto:es-discuss at mozilla.org)
> https://mail.mozilla.org/listinfo/es-discuss
>  
>  


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20120329/fcbd1399/attachment-0001.html>


More information about the es-discuss mailing list