Function proxy length (Was: length property value for functions with parameter enhancements)

Andreas Rossberg rossberg at google.com
Wed Aug 31 06:48:31 PDT 2011


On 31 August 2011 15:21, Tom Van Cutsem <tomvc.be at gmail.com> wrote:

> I coded up a hypothetical Proxy.createConstructor function that creates a
> function proxy initialized according to ES5.1 section 13.2: <
> https://gist.github.com/1183514>


Nit: invoking callTrap.call assumes that callTrap has an actual call method.
But you want to work this for call traps that are themselves proxies and
don't necessarily have that (or don't we?). So you need to do

  Function.prototype.apply.call(callTrap, instance, arguments)

(assuming nobody messed with that either, of course).

This turns up quite frequently, in fact. With proxies, it is really
error-prone that all these functions have been made available as methods on
{Object,Function}.prototype, instead of being separate. Morally, these
methods used to be part of the implicit contracts of object and function
types that everybody relies on. But proxies break those contracts! At least
for functions, this is really a problem IMO (for plain objects, the contract
was already invalidated by allowing Object.create(null)).

/Andreas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20110831/1e4a5b8b/attachment.html>


More information about the es-discuss mailing list