Arrow binding

Oliver Hunt oliver at apple.com
Mon Apr 23 08:43:14 PDT 2012


On Apr 23, 2012, at 8:32 AM, John J Barton wrote:

> 
> 
> On Mon, Apr 23, 2012 at 3:53 AM, Alex Russell <alex at dojotoolkit.org> wrote:
> 
> The new forms we're adding (methods and arrows) have the potential to change this radically, causing a large percentage of functions encountered by programmers to have binding. If that binding is hard-binding, .call() and .apply() break in the minds of users. Perhaps that's fine by you, but in addition to being a contractual failure, it removes a form of genericness which is unique in the language.
> 
> Sorry if I missed reading about this but: why can't we re-bind 'this" in bound functions when using call(), apply() ? I'm sure it will make more work for JIT optimizers but they are very good and love this kind of problem.

Because the semantics would be difficult to implement -- jit or otherwise -- and difficult to specify otherwise :-(

The more serious issue though is that of program behaviour -- if a developer has strongly bound this, it is reasonable to expect that they had some reason to do so.  If you provide a mechanism that can bypass that binding you can break program abstraction, potentially allowing security bugs in the SES/Caja type language models.

It would also imply being able to rebind |this| in bound functions, which would be insane.

--Oliver

> 
> jjb
> _______________________________________________
> 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/20120423/406fbbee/attachment.html>


More information about the es-discuss mailing list