Re: [whatwg/webidl] Maplike/setlike iterators shouldn't use MapIteratorPrototype/etc (Issue #1142)

> To the best of my knowledge, I have maintained consistency with real Map iterators

Yeah I think you're fine currently. The main details to worry about are iteration order and coercing `-0` to `0` in keys. ([Infra](https://infra.spec.whatwg.org/#maps) just says "no key appearing twice", so the second thing will be a problem if there is ever a maplike or setlike which allows `number`s as keys.)

> > that means that engines have to either use the same underlying data structure for those things as for Maps,
>
> This would be completely fine, probably ideal in fact. This change was meant to make messing around with the contents of a maplike/setlike actually doable for human spec editors, rather than requiring everyone to know and get perfectly right the precise dance of algos that manipulating ES objects requires.

To be clear, by "underlying data structure", I mean the actual C++ object which backs the thing, not the spec-level thing used to talk about it in algorithms.

My thinking is that WebIDL maplikes specify types more narrowly than ES Maps do, which might lead to wanting a different backing store. This is particularly relevant if there's ever a maplike which has only a small number of possible keys, which is a place where you'd really want to back it by something other than a hashmap.

But maybe this won't actually come up in practice. This is pure speculation on my part; I wanted to make sure the possible downside is recognized but I don't have any idea how likely or important it actually is.

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

Message ID: <whatwg/webidl/issues/1142/1119138449@github.com>

Received on Thursday, 5 May 2022 23:33:10 UTC