arrow function syntax simplified

Dmitry Soshnikov dmitry.soshnikov at gmail.com
Sun Apr 1 00:30:09 PDT 2012


On Apr 1, 2012, at 12:12 AM, Axel Rauschmayer wrote:

>> Axel Rauschmayer wrote:
>>> My bad. It is, minus [[Construct]] and *.prototype. I misremembered how bind() works.
>>> 
>>> On Mar 30, 2012, at 0:01 , Axel Rauschmayer wrote:
>>> 
>>>> Interesting. So x => x * x is not just syntactic sugar for
>>>> 
>>>>     function (x) { return x * x }.bind(this)
> 
> On Mar 31, 2012, at 2:54 , Brendan Eich wrote:
> 
>> We do not want to delegate to a target function that can [[Construct]], because there is no such target function -- we're not trying to sugar .bind on a full function. That is too expensive and general (no pre-args, no full function under the hood).
> 
> 
> Ah, good. But one can use the above (pseudo-)desugaring to predict the behavior of arrow functions, right? That is, there is no observable difference.
> 

There is, again, the difference in terms of delegation to the target's [[Construct]] in case of a bound function, see the spec ("bound" per ES5, of course, since, as Brendan notices, it's not just a syntactic sugar, but a new special type of functions).

Dmitry


> -- 
> Dr. Axel Rauschmayer
> axel at rauschma.de
> 
> home: rauschma.de
> twitter: twitter.com/rauschma
> blog: 2ality.com
> 
> _______________________________________________
> es-discuss mailing list
> 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/20120401/03ea795d/attachment-0001.html>


More information about the es-discuss mailing list