I am curious if https://github.com/zenparsing/es-function-bind would be related, since it would allow bound function calls to be made by using `obj::fn` while `obj.fn` would result in the unbound first class function.
On Mon, Jul 13, 2015 at 10:02 AM, Brendan Eich <bren...@mozilla.org> wrote: > You're counting on the property assignment being moved into the > constructor, where `this` is bound. In a class body in ES6 (without > property assignment extension), especially in the top level where method > defintiions go, `this` isn't obviously bound to the newly constructed > instance. > > Ok, that's kind of a nit, or an observation. No worries. > > Bigger question is what we want: method per instance allocation cost, > which what you did imposes? Or something that can be more efficiently > implemented, such as what Strong/SoundScript proposes (last I looked). The > latter is what Java and C++ do. Then the trick is enabling first-class > function extraction from method, which is a pay-for-what-you-ask-for > alternative to allocation per method per constructed instance. > > /be > > Matthew Robb wrote: > >> Are there any proposals or any discussions around solving the problem of >> instance bound class methods with some sugar? >> >> There are examples of people doing things like this: >> https://github.com/reactjs/react-future/blob/master/01%20-%20Core/01%20-%20Classes.js#L31 >> >> My proposal would be to extend method shorthand syntax to support the >> arrow: >> >> ``` >> class A extends React.Component { >> handleClick(event)=> { >> ... >> } >> } >> ``` >> Which would be sugar for: >> ``` >> class A extends React.Component { >> handleClick = (event)=> { >> ... >> } >> } >> ``` >> - Matthew Robb >> _______________________________________________ >> es-discuss mailing list >> es-discuss@mozilla.org >> https://mail.mozilla.org/listinfo/es-discuss >> > _______________________________________________ > es-discuss mailing list > es-discuss@mozilla.org > https://mail.mozilla.org/listinfo/es-discuss >
_______________________________________________ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss