On Dec 21, 2010, at 5:00 PM, Brendan Eich wrote:

> On Dec 21, 2010, at 4:51 PM, Oliver Hunt wrote:
> 
>>> But what is an array index, then? uint32 is not a type in the language. 
>>> Would proxy[3.14] really pass a double through?
>> Yes, I would expect no coercion of any non-object.  The reason for 
>> disallowing objects is safety afaik, those arguments don't apply to 
>> non-objects.
>> 
>>> Array elements are named by a weird uint32 index name, with consequences on 
>>> 'length' (but only up to 2^32 - 1 for length). I don't think passing the 
>>> property name through uncoerced helps, unless you assume a normalizing 
>>> layer above all name-based operations that specializes to index-names per 
>>> Array's uint32 magic weirdness.
>> 
>> And people are welcome to implement those semantics if they so desire.
> 
> If engines do not agree on whether 0xffffffff as a property name goes through 
> a proxy get trap as a number and not a string, we have a problem.
> 
> Not all engines optimize 0xffffffff to the same (uint32) value; some keep it 
> as a string since it doesn't fit in an int32.

What does that have to do with anything?  That's an internal implementation 
detail, not something that is directly observable from js (you can direct 
indirectly through timing, etc)

>> I just see no reason to artificially limit behaviour.
> 
> The spec must prescribe exactly what is coerced and what is not, or we lose 
> interoperation.

Okay, this and the prior comment indicate that you're missing what I am saying.

I am not suggesting that we expose the internal optimisations for avoiding 
int->string->int.

I am being very precise: anything that is _not_ an object goes is passed 
through with no coercion of any kind.

eg.
assuming the get trap is:
function getTrap(property) {
    log(property + ": " + typeof property);
}

myProxy[0] => 0: number
myProxy[1.5] => 1.5: number
myProxy["0"] => 0: string
myProxy[true] => true: boolean
myProxy[undefined] => undefined: undefined
myProxy[null] => null: object // questionable - null is classed as an object 
but i doubt many people actually think of it in that way
myProxy[somePrivateNameThingy] => ???: ???? // I have no idea what typeof 
privatename or String(privateName) are expected to do

--Oliver


_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to