Open littledan opened 5 years ago
See also #106. I think we mostly want object identity here, except for primitive data types. Most specifications already assume those semantics when it comes to equality.
I think the second sentence doesn't really relate to the first that much and probably needs to be reworded. Maybe something like:
For a list list and an index index, list[index] exists, if index is not out-of-bound for list.
(I'd expect [[PlatformBrand]]
to be a set, but yeah, you'd use contains.)
Can sets contain things like Records? I'm not sure if those are considered to have object identity.
So the second sentence was just an independent definition of "exists"? I don't understand why that's necessary, given the definition of "exists" earlier in the section.
No, I think it's meant as looping over the list, comparing the input item with the items that result from looping, and returning true if they're "equal". Anyway, I agree with you that this could use some refactoring.
Some definitions in Infra are fairly vacuous. E.g. contains delegates to an undefined "appears in" concept, iterate to "on each item in order", append and prepend to "add". The intention is roughly "you already know what this vague concept is, but here's the exact word you can use and reference".
We could probably redefine "contains" in terms of equals and iterate, instead of "appears". But I'm not sure how far we should pursue such a program. The endpoint of making these definitions rigorous is basically axiomatic set theory.
From https://infra.spec.whatwg.org/#list-contain:
I'm confused about a couple points here:
(Context: I'm wondering about how to use an Infra set for the
[[PlatformBrand]]
(https://github.com/heycam/webidl/issues/97), and possibly also for private method brands (https://github.com/tc39/proposal-decorators/issues/180). It looks like I'd use thiscontains
algorithm to check membership, right?)