On Thu, Mar 29, 2012 at 12:02 PM, Brendan Eich <[email protected]> wrote:
> Brendan Eich wrote: > >> Irakli Gozalishvili wrote: >> >>> Few questions on this new arrow functions: >>> >>> let foo = x => x * x >>> >>> >>> 1. What is foo.prototype ? >>> 2. What does new foo(y) does ? >>> >> >> The idea with arrow function syntax (as opposed to block-lambda revival) >> was to be as close to "just syntax" for functions. Obviously we've made >> early-error restrictions but this design goal still stands. So the answers >> are: >> >> 1. Same as for any user-defined function (a fresh Object instance). >> 2. Same as for any user-defined function. >> > > Oops, I left off something important. Since we agreed on lexical |this| > binding, there's no way for the new object to flow into the arrow function. Just a small note related to lexical `this' -- if it's just a syntactic sugar for the `bind' method, then [[Construct]] probably should (for consistency?) work, providing newly created object -- because a bound function delegates to the target's [[Construct]] per ES5. Dmitry > So I'm wrong, the answers are: > > 1. Same as for any built-in function: no .prototype property at all. > 2. Arrow-functions lack [[Construct]] so you cannot 'new' them. > > This makes arrows like built-ins. They're still functions, per my other > answers. > > I'll update the strawman (which should be promoted shortly). > > Thanks for the good questions! > > /be > > ______________________________**_________________ > es-discuss mailing list > [email protected] > https://mail.mozilla.org/**listinfo/es-discuss<https://mail.mozilla.org/listinfo/es-discuss> >
_______________________________________________ es-discuss mailing list [email protected] https://mail.mozilla.org/listinfo/es-discuss

