[Webkit-unassigned] [Bug 26382] [ES5] Implement Function.prototype.bind
bugzilla-daemon at webkit.org
bugzilla-daemon at webkit.org
Thu Apr 28 09:35:18 PDT 2011
https://bugs.webkit.org/show_bug.cgi?id=26382
--- Comment #29 from Mark S. Miller <erights at gmail.com> 2011-04-28 09:35:16 PST ---
(In reply to comment #25)
>
> JS can reasonably emulate the [[Call]] behavior of .bind() but not
> its [[Construct]] behavior. This is important because the [[Construct]]
> behavior of .bind() is the only way to implement a correct var-args
> construction (new) operation in ES5.
To expand on that, given the ES5 specified Function.prototype.bind, one can implement a "construct(f, args)" operation as follows:
> function construct(f, args) {
> var bound = Function.prototype.bind.apply(f, [null].concat(args));
> return new bound();
> }
> construct(Date, [1957, 5, 27])
Thu Jun 27 1957 00:00:00 GMT-0700 (PDT)
Without the specified primitive implementation of bind, I know of no way for a pure JavaScript shim to correctly emulate this behavior, and therefore no way for an ES-next to ES5 compiler to correctly compile "new f(...args)" to ES5.
--
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
More information about the webkit-unassigned
mailing list