Bait taken: Arguments about arguments
brendan at mozilla.com
Thu Jan 15 12:03:01 PST 2009
On Jan 15, 2009, at 9:50 AM, Erik Arvidsson wrote:
> Sorry for being late to the party.
> Is there a reason why we need to restrict the argArray to apply this
> much? I think it would be very useful to allow anything array like
Please define "array like" and give examples (possibly including DOM
nodelists, which thanks to "live update" are are neither lists nor
arrays, rather more like cursors).
We had a structural type for it in ES4. ES3.1 has no such type system
or spec language. It's too late to add anything like this. But for
Harmony, proposing (possibly more than one) "array-like" notion that
could be used to extend the language is fair game.
> 2009/1/15 Brendan Eich <brendan at mozilla.com>:
>> On Jan 14, 2009, at 9:16 PM, Mark S. Miller wrote:
>> On Wed, Jan 14, 2009 at 7:08 PM, Brendan Eich <brendan at mozilla.com>
>>> When in doubt, use brute force. ES3 already did. Quoting from its
>>> spec for Function.prototype.apply:
>>> 220.127.116.11 Function.prototype.apply (thisArg, argArray)
>>> [...] Otherwise, if argArray is neither an array nor an arguments
>>> object (see section 10.1.8), a TypeError exception is thrown. If
>>> argArray is either an array or an arguments object, the function
>>> is passed the (ToUint32(argArray.length)) arguments argArray,
>>> argArray, …, argArray[ToUint32(argArray.length)–1]. [...]
>> Yes, this is the spec text I quoted as well. But I don't understand
>> it or your "use brute force" answer.
>> Sorry, didn't mean to rehash.
>> How does Function.prototype.apply determine that argArray is an
>> arguments object?
>> ES1-3 leave this unspecified. But they talk about "an arguments
>> object [being] created" (10.1.8), etc. and it's easy enough to
>> implement the spec -- there are many implementations. SpiderMonkey
>> uses a distinct class whose name is "Object", to satisfy what is
>> specified ([[Prototype]] is the original Object.prototype value).
>> Do we need really need to say more?
>> We need to do something, since as it stands the operational spec is
>> unimplementable in terms of the specified semantic state.
>> The spec has a domain of discourse that includes "an arguments
>> object". It's implementable without error. Sure, we could add
>> another internal property to avoid this appeal to an unspecified
>> way of distinguish arguments objects from all other objects. Again
>> I'm loath to over-invest.
>> Es3.x-discuss mailing list
>> Es3.x-discuss at mozilla.org
More information about the Es-discuss