- From: Boris Zbarsky <bzbarsky@MIT.EDU>
- Date: Mon, 02 Apr 2012 20:26:49 -0400
- To: Cameron McCormack <cam@mcc.id.au>
- CC: public webgl <public_webgl@khronos.org>, "public-script-coord@w3.org" <public-script-coord@w3.org>
On 4/2/12 7:20 PM, Cameron McCormack wrote: > I want to allow object with indexed properties to be passed to objects > expecting a sequence<T> or T[] type, so that you can do for example: > > void f(sequence<Node> nodes); > > and be able to pass in a JS Array of Node objects or a NodeList. I make > interfaces with indexed properties not distinguishable from sequences > and arrays so that there isn't a value that would match both types. Or you could make it distinguishable and check for the right interface before trying the generic conversion. > I think removing the Float32Array overload will make passing JS Arrays > of Numbers and Float32Array objects work. But require copies in the process, no? That seems highly undesirable in this case. > But note that *any* object > that has indexed properties will be allowed to be passed here, e.g. a > Uint8Array. If we want to disallow that, then I think that is > incompatible with the NodeList example above. Not if we place requirements on the return values of the indexed properties or something. But that can get complicated. > But if we're fine with > Uint8Array being passed in and matching the float[] overload That seems up to the WebGL folks here..... > then just > changing those types to be distinguishable, and making the argument > resolution algorithm match the specific interface types before the > "catch all" array/sequence types should work. Indeed. -Boris
Received on Tuesday, 3 April 2012 00:27:18 UTC