Arrow binding

Axel Rauschmayer axel at rauschma.de
Mon Apr 23 07:56:14 PDT 2012


On Apr 23, 2012, at 16:17 , Alex Russell wrote:

> Having done this dance a couple of times, let me suggest to you that
> the method form will *eventually* end up at a per-class getter on the
> prototype which vends an instance function which is bound. People will
> (reasonably) want binding of some sort.


An important use case. However, wouldn’t it be simpler to achieve the same goal by allowing the following two operations to co-exist?

- "get": obj.method invokes the getter – which hard-binds on demand (but might cache via a weakmap).
- "call": obj.method() invokes the actual method.

Hence, in addition to getters and setters, we would have "callers". If a property doesn’t have a caller then obj.method() would first invoke the getter and then try to call the result.

-- 
Dr. Axel Rauschmayer
axel at rauschma.de

home: rauschma.de
twitter: twitter.com/rauschma
blog: 2ality.com

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


More information about the es-discuss mailing list