Function identity of non-configurable accessors

David Bruant bruant.d at gmail.com
Wed Dec 19 08:15:38 PST 2012


Le 19/12/2012 16:34, Brandon Benvie a écrit :
> That's easily solved by making the accessor have a null prototype and 
> frozen though.
True, but it makes that you can't re-apply these getters and setters 
with .call.
Since the getter doesn't inherit from Function.prototype any longer, you 
have to go through

     Function.prototype.call.call(webIDLGetter, context)

or

     var call = Function.prototype.call.bind(Function.prototype.call);
     call(webIDLGetter, context);

Since recontextualizing getter/setter is probably one of their main use 
case, I wish this wasn't the chosen solution.
I'd like to point out that recently on Twitter, Eddy Bruel, (who among 
other things implemented direct proxies on SpiderMonkey) shared his 
trouble understanding the Function.prototype.call.bind trick [1] If he 
has trouble, I'm sure thousands (millions?) of less educated JS devs 
will do too.

I prefer the configurable:true solution so far.

David

[1] https://twitter.com/ejpbruel/status/276747606951071744


More information about the es-discuss mailing list