Methods: automatic binding on read?

Brendan Eich brendan at mozilla.org
Fri Apr 13 14:40:29 PDT 2012


You mean "automatic binding with memoization on read", I hope.

Otherwise you break o.m === o.m.

This can be implemented with accessors and weakmaps, of course. That 
says two things to me:

1. It ain't cheap so should not be default, esp. not for method 
definition shorthand.

2. We should let the cows make a pavement-worthy path.

/be

Axel Rauschmayer wrote:
> I wonder if, with the concise method notation for literals (and 
> possibly class declarations), one couldn’t introduce three modes of 
> accessing a property: Read (getter), write (setter) and call (call 
> interceptor?).
>
> - Manually assigned functions: everything works as it does now.
> - Concise method notation:
>    - Read: bind `this`
>    - Write: apply defineMethod to the argument (not sure about this one)
>    - Call: same as before
>
> I have no idea how this would fit into the current semantics, so it 
> might be a silly idea, but it would eliminate a common source of bugs.
>
> -- 
> Dr. Axel Rauschmayer
> axel at rauschma.de <mailto:axel at rauschma.de>
>
> home: rauschma.de <http://rauschma.de>
> twitter: twitter.com/rauschma <http://twitter.com/rauschma>
> blog: 2ality.com <http://2ality.com>
>
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss


More information about the es-discuss mailing list