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

Tom Van Cutsem at
Wed Aug 31 06:21:20 PDT 2011

I coded up a hypothetical Proxy.createConstructor function that creates a
function proxy initialized according to ES5.1 section 13.2: <>

Given the ease with which this can be expressed, I'm not sure it merits
dedicated support, unless I overlooked something.


2011/8/31 Tom Van Cutsem < at>

> 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 so:
> 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).
> Cheers,
> Tom
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list