- From: Cameron McCormack <cam@mcc.id.au>
- Date: Sat, 30 Oct 2010 17:19:13 +1300
- To: Anne van Kesteren <annevk@opera.com>
- Cc: Garrett Smith <dhtmlkitchen@gmail.com>, Erik Arvidsson <arv@chromium.org>, public-webapps@w3.org
Cameron McCormack: > > I don’t know that sequence is appropriate for this. They are meant > > to be for pass-by-value lists. > Anne van Kesteren: > I'm not sure I follow this. Could you elaborate a bit? As currently defined, sequence types are used solely to represent lists of values, and not objects that have other methods on them. Also, those lists are passed by value. If you had an operation that took a sequence<long> argument, then in ECMAScript you could pass an Array object where each of the elements were treated as longs (and converted appropriately). The object on which you called the method wouldn’t be able to keep a reference to the Array. This is kind of different from NodeLists etc., which are objects that keep a list of values. You can pass references to these objects around and not expect a copy of the elements to be taken each time you do that. Array types are intended to be like these objects, in that copies won’t be made of their element lists. They still don’t allow operations to be defined on them, though, if you are looking for that. > >Is the issue here that you can’t use a base interface because then you > >would lose some type specificity, e.g. > > > > interface Collection { > > attribute unsigned long length; > > getter any item(unsigned long index); > > } > > > >where you need to use “any” because you don’t know what the type of the > >derived interface elements will be? > > Well, and you would need to define that base interface somewhere and > all other specifications would need to use it. A minor issue, I guess. > But I thought this was the point of sequence. I have been using it > that way in the CSSOM at least to replace all these dreaded > SomethingList interfaces/objects. Maybe we should introduce something > else for it? Depends what you are using them for. For example if you have an attribute of type sequence<T>, that’s almost certainly not what you want. (And in fact I should disallow it.) You don’t want a whole new Array object constructed each time you get the property value. So it sounds like array types are more appropriate here. I don’t think anyone is using array types yet. Consequently, they could do with some review. Have a read through http://dev.w3.org/2006/webapi/WebIDL/#es-array to see how they’re meant to be implemented in ECMAScript. Having funky [[DefineOwnProperty]] behaviour, I’m sure some people will have issues with it. Maybe one day it’ll be possible to define array-like proxy objects in ECMAScript, in which case we could target them instead. -- Cameron McCormack ≝ http://mcc.id.au/
Received on Saturday, 30 October 2010 04:20:05 UTC