You may be interested in http://code.google.com/p/es-lab/source/browse/trunk/src/ses/repairES5.js#1283
A reason your exercise is more pressing than it may seem is that f.p.bind is still missing on WebKit Nightly. See < https://bugs.webkit.org/show_bug.cgi?id=26382#c29>. I agree with your assessment that it is not possible to do a conformant implementation in JavaScript. On Tue, Aug 30, 2011 at 9:42 AM, 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). Also, > Function.prototype.bind is writable and configurable. > This leads to the situation that, on my code, when i write f.bind(obj), it > is either unreliable or for it to be reliable, i am forced to make at least > Function.prototype.bind non-configurable (and non-writable or a getter that > returns the same and correct value) (and do the same thing to > Function.prototype.call/apply if i'm emulating Function.prototype.bind) or > add a bind own property to every function i am susceptible to bind. > > A syntax construct allowing reliable binding without having me to go over > one of the previous solutions would be welcome I think. > > The CoffeeScript-inspired arrow_function_syntax strawman [1] seems to have > such a syntactic construct (though i'm not really sure i understand it, i'd > need more examples). > What i wish is a syntax equivalent to Function.prototype.bind (which would > take a function and an object as input and generate a bound function as > output) > > David > > [1] http://wiki.ecmascript.org/doku.php?id=strawman:arrow_function_syntax > > Ps : I sent this message already on August 19th and August 26th, but i > haven't seen it popping up on es-discuss, sorry for the spam if it appears > several times > > _______________________________________________ > es-discuss mailing list > [email protected] > https://mail.mozilla.org/listinfo/es-discuss > > -- Cheers, --MarkM
_______________________________________________ es-discuss mailing list [email protected] https://mail.mozilla.org/listinfo/es-discuss

