Re: [heycam/webidl] A new approach to array-ish classes (#796)

Thank you for thinking about this!

It's not quite clear to me how the executor bits fit into the proposal.  Is there an explanation somewhere?

Presumably there should be some `length` getters (and setters; see below) on these interfaces.

For `ReadonlyArray`, it seems like the main things we want are:

1) Have `Array.prototype` on the proto chain.
2) Set `@@isConcatSpreadable`

`@@species` thing is not an issue; the array methods in ES only look at `@@species` if the object tests true for `isArray`; otherwise they create a vanilla `Array`, which is the behavior we want.

In theory we could do this for everything with an indexed getter already, modulo possible web compat issues for existing types, right?  So the main benefits (and they're useful benefits!) of `ReadonlyArray` are that we know there is no web compat issue and we can avoid having a silly `item` method on it.  Is that a correct summary of the `ReadonlyArray` situation?

For `ReactToAbleArray`, same things apply plus we want a writable length that allows setting length to anything <= current length (e.g. `Array.prototype.push` sets the length after doing the index-based assignment, so we need to support at least setting to current value to support `push` if we use the Array methods).

At least on the Gecko side, I suspect implementation complexity is much lower if we just do `[LegacyArrayClass]` instead of reimplementing all of that stuff.  But maybe I'm missing something; I'd like to know what implementation benefits would come from the reimplementation approach.

Fundamentally, if we just reintroduce `[LegacyArrayClass]` (which is funny, given Gecko had support for it and was using it, and people told us they would never implement it so we should remove it!) and define that it sets `@@isConcatSpreadable`, this is all something specs could do themselves; the annoying part is the proliferation of interfaces involved and the fact that they might not do it quite right, yes?

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/heycam/webidl/issues/796#issuecomment-530839952

Received on Thursday, 12 September 2019 14:01:01 UTC