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

Mark S. Miller erights at
Mon Aug 29 08:21:10 PDT 2011

On Mon, Aug 29, 2011 at 7:43 AM, Tom Van Cutsem < at> wrote:

> (changed subject to fork off discussion on function proxies)
> 2011/8/29 Allen Wirfs-Brock <allen at>
>> On Aug 27, 2011, at 6:12 AM, Andreas Rossberg wrote:
>>  > True, and actually, there are more issues with length & function
>> > proxies. I don't have my notes with me right now, but for example, it
>> > is not clear at all what length Function.prototype.bind should set
>> > when called on a function proxy. 0? 1? Should it try to get the length
>> > property from the proxy and subtract N? What if length is not defined
>> > on the proxy, or not a (natural) number?
>> The ES5.1 spec.  defines how how bind determines the length for the
>> function it creates based upon the length property of the target function.
>>  I would expect the same rules would apply when the target is a function
>> proxy.
> I see two options here:
> a) either query the function proxy for its "length" property via its "get"
> trap, and convert the result using ToInteger, introducing a new error case
> if the conversion fails.
> b) or determine "length" based on the function proxy's call trap (which is
> presumably a non-proxy function. If it is a function proxy itself, recurse)
> The spec currently uses the wording: "Let L be the length property of
> Target ..." (ES5.1 section
> If that is not equivalent to "Let L be the result of calling the [[Get]]
> internal method of Target with argument "length"", then option b) seems
> better.
> There is precedent for using the call trap as a substitute for the function
> proxy:  will also use the
> call trap's toString representation rather than trapping the handler.

I don't have any strong preference regarding #a vs #b. However, I don't
think is a relevant
precedent. For .length, we have the choice of #a or #b. For, what other option could there be besides the choice we

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

More information about the es-discuss mailing list