Necessity of a syntax construct for bind
david.bruant at labri.fr
Tue Aug 30 09:42:11 PDT 2011
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  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)
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
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the es-discuss