W3C home > Mailing lists > Public > public-html@w3.org > September 2009

Re: ECMA TC 39 / W3C HTML and WebApps WG coordination

From: Cameron McCormack <cam@mcc.id.au>
Date: Sat, 26 Sep 2009 07:11:41 +1000
To: Brendan Eich <brendan@mozilla.com>
Cc: Jonas Sicking <jonas@sicking.cc>, Anne van Kesteren <annevk@opera.com>, Sam Ruby <rubys@intertwingly.net>, Maciej Stachowiak <mjs@apple.com>, es-discuss Steen <es-discuss@mozilla.org>, HTML WG <public-html@w3.org>, public-webapps@w3.org
Message-ID: <20090925211140.GA24110@wok.mcc.id.au>
Hi Brendan.

Brendan Eich:
> The struggle to formalize ArrayLike, which seems like a common goal
> for ES the core language and for WebIDL's ES bindings, makes me want
> to give an exception to the "catchalls considered harmful for new
> interfaces" injunction. I agree that indexing into array-likes, with
> no liveness magic, seems containable and desirable. ES folks haven't
> nailed down ArrayLike yet (our fault) and we would benefit from
> collaboration with WebIDL folks here.

So currently in Web IDL there are three ways to get objects with
properties that have non-negative integer names: sequences, arrays and
regular interfaces with index getters.  The definitions for sequence<T>
and T[] types in Web IDL are relatively recent, but they are probably
more in line with the kinds of thing you’re looking for with ArrayLike
(without having re-read that thread yet).

The main difference between sequences and arrays is that sequence types
are effectively pass-by-value and use native Array objects, while array
types are host objects that act similarly to native Arrays, but with
appropriate IDL ↔ ECMAScript type conversions.  IDL arrays have the
native Array prototype object in their prototype chain.  A given IDL
array an be designated as read only, so that assigning to length or
array index properties has no effect.

There are no ES implementations of IDL sequences or arrays yet as far as
I know.

The third way, defining a regular interface with an index getter (and
maybe a setter) is currently used.  It’s implemented with special
[[Get]] (and [[Put]]) behaviour, which I guess is what you would like to
avoid.  However it’s not just a simple catchall – such objects are
defined to gain and lose properties with the appropriate index names as
appropriate for the interface.  This is done pretty much just so that
‘in’ and hasOwnProperty return true for array index properties, which is
needed for HTMLCollection and the like.

(Cross-posting to these three lists makes me feel funny, although I
recognise that these issues involve all three groups.)

Cameron McCormack ≝ http://mcc.id.au/
Received on Friday, 25 September 2009 21:12:46 UTC

This archive was generated by hypermail 2.3.1 : Thursday, 29 October 2015 10:15:51 UTC