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

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 ≝

Received on Friday, 25 September 2009 21:12:45 UTC