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

Tom Van Cutsem at
Wed Aug 31 04:24:35 PDT 2011

2011/8/30 Brendan Eich <brendan at>

> On Aug 30, 2011, at 2:16 PM, David Bruant wrote:
> Actually that's what current function proxies do by default (no .prototype
> unless otherwise specified). My suggestion is to put a .prototype by default
> with keeping the option to opt-out (same with .length, etc.)
> Right, of course function proxies have to trap in order to emulate
> .prototype and other properties.

Indeed, that was our intent: fproxy.prototype and fproxy.length are
determined by the handler via the "get" trap.
This should work fine for fproxy.prototype (and it is actually consulted
when evaluating |obj instanceof fproxy|.)

For fproxy.length, the handler object can only return the call trap's length
if it has a reference to the call trap, which as David points out, in the
general case it does not. OTOH, typically a function proxy will wrap some
other target function f, in which case the handler would simply return
f.length, so I don't know whether this issue is such a big deal.

If one wraps an existing function f using the default ForwardingHandler like
var fproxy = Proxy.createFunction(new ForwardingHandler(f), f);

Then fproxy.prototype, .length, .arguments, and .caller will all work as
expected. So the default ForwardingHandler is in a sense already the
convenient library that Andreas alluded to.

I do notice that .prototype and .length are non-configurable properties, so
that ups the ante for proxies being able to emulate non-configurable
properties (more about that later).

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list