On Tue, Aug 30, 2011 at 6:42 PM, David Bruant <[email protected]> wrote:
> Hi, > > A couple of people (including myself) have been working on trying to > implement a Function.prototype.bind pure-JS implementation as close to the > spec as possible. > Despite the fact that this is impossible, all implementations relied on the > built-in Function.prototype.call (or Function.prototype.apply). > I've had that problem in other cases too. It's interesting that .call/.apply can't be protected from tampering without freezing them. If there was a function, say Function.callFunction, that allowed you to write the equivalent of foo.call(bar, baz) as Function.callFunction(foo, bar, baz), then you could store a copy of callFunction in a safe place and not have to worry about Function.prototype.call being modified. Any attempt I have tried of extracting the call functionality without leaving a visible trace on the existing objects can be thwarted. Most other functions can be extracted to local variables and called later on the appropriate object (using .call) if you want to save an environment. > A syntax construct allowing reliable binding without having me to go over > one of the previous solutions would be welcome I think. > A reliable .call could probably also achieve the same. /L
_______________________________________________ es-discuss mailing list [email protected] https://mail.mozilla.org/listinfo/es-discuss

