W3C home > Mailing lists > Public > public-webapps@w3.org > January to March 2011

Re: [FileAPI] Why is FileList a sequence?

From: Cameron McCormack <cam@mcc.id.au>
Date: Fri, 11 Mar 2011 14:41:03 +1300
To: Ian Hickson <ian@hixie.ch>
Cc: Anne van Kesteren <annevk@opera.com>, Simon Pieters <simonp@opera.com>, Arun Ranganathan <arun@mozilla.com>, public-webapps <public-webapps@w3.org>
Message-ID: <20110311014103.GH7360@wok.mcc.id.au>
Ian Hickson:
> Web Apps 1.0 will change if you need it to. Don't constrain on my account 
> here. I'll do whatever you think we should do. The only places I use it 
> are in an argument to a method because I want to allow authors to pass in 
> literal JS Arrays of values, and on a NodeList descendant where I just 
> wanted the user of the API to be able to get a JS Array of values. I don't 
> think there's much implementation compatibility constraint here.


The latter isn’t a good use, BTW, as mentioned in the reply to Anne,
because it would mean a fresh Array object is constructed each time you
get the values property of PropertyNodeList.  So for what you might
expect to be a common usage pattern,

  for (var i = 0; i < myPropertiesCollection.values.length; i++) {

it’s going to result in a lot of wasted work.  To make it clear that’s
going to happen, I’d recommend making it a method instead.

Or if you want to retain the property style access, you could use T[]
instead, and state that it is a read only array.  The object returned by
the property wouldn’t be a real JS Array, though.

(Or you could go the route of defining an interface with index getters.)

> (Are the other two implemented by any browsers?)

Not that I’m aware of.

I think sequence<T> is fine for the purpose of accepting a JS Array of
items as a method argument.  Presumably the requirement to have
something like that in WA 1.0 isn’t going away, and there isn’t another
way to do that in Web IDL currently, so unless there are concrete
problems with sequence<T> or anyone has ideas on how to do it better,
I’ll just leave it alone for now.

Cameron McCormack ≝ http://mcc.id.au/
Received on Friday, 11 March 2011 01:41:54 UTC

This archive was generated by hypermail 2.3.1 : Friday, 27 October 2017 07:26:30 UTC