Omissions in IDL sequence and IDL array conversion to ES array

Hi.

I have some questions about the following two sections
* http://dev.w3.org/2006/webapi/WebIDL/#es-sequence
* http://dev.w3.org/2006/webapi/WebIDL/#es-array

For the sake of the examples, exampleFunction is a function which converts  
the first argument to an ES Array.

a)
First, both mention to [[Get]] the property of name length from the object  
and call ToUInt32 on the value. What happens if the object does not have a  
length property? Should a TypeError be thrown, or an array of length 0  
assumed?

b)
What happens is a function object is passed ?
Example:

# var f = new Function("arg1", "arg2", "code");
# exampleFunction(f);

Function objects have immutable lengths, but by default no indexed  
properties. Would it make sense for native function objects to throw a  
TypeError? Passing a function as an array would perhaps most likely be a  
programming error anyway.

c)
According to the spec a String object would be converted into an array, by  
separating each character into each array position, because Strings by  
default have a length property, just like atomic strings, and indexed  
properties. However atomic strings aren't objects, hence the algorithm  
would fail.

e.g.:
# exampleFunction(new String("abc"))
would convert the argument to
# ["a","b","c"]

Is this expected? It does seem completely overkill though given that  
strings internally are not really represented as an array of individual  
characters. It might be useful but would most likely be a programming  
error.

Some cases:
# exampleFunction([new String("arg")]) // passes ["abc"]
# exampleFunction(new String("arg")) // passes [a,b,c]
# exampleFunction("arg") // throws TypeError

All three produce very different results.

Thank you.

Received on Tuesday, 3 January 2012 13:15:08 UTC