18:03 | <ptomato> | any editor guidance on https://github.com/tc39/proposal-temporal/issues/2531 ? is the Set specification type something that would be useful to use more broadly in abstract operations not pertaining to the memory model? |
18:35 | <littledan> | (not an editor, but what we're really missing is a Map type in the spec... might make sense to fix this locally for Temporal but I'd love to see more intuitive data structures more broadly, including set, ideally somehow shared by https://infra.spec.whatwg.org if possible) [Edit: By "fix this locally" I meant, just use a List for now] |
18:40 | <bakkot> | ptomato: I think probably it's simpler to use a List, and explicitly skip over duplicates, possibly with the assistance of a helper like the SetDataHas helper added in the set methods proposal (https://tc39.es/proposal-set-methods/#sec-setdatahas). contra littledan I think it's generally best to minimize the number of "foundational" types in the spec - there's less to reason about that way. (e.g., a mathematical set isn't ordered, so when you convert one to a List the resulting order is simply not specified, which you probably don't want even if it doesn't actually end up mattering given how you happen to be consuming that List right now) |
18:40 | <littledan> | bakkot: Did you see how the WHATWG Infra doc doesn't add lots of foundational types, but defines some in terms of others? |
18:42 | <bakkot> | littledan: yup and I've also seen e.g. https://github.com/whatwg/infra/pull/451 which points to some of the difficulties with that approach - specifying a whole type, with all of its attendant semantics, is actually quite a bit of work and sometimes has non-obvious implications for consumers |
18:43 | <bakkot> | ptomato: I should say also that in that particular case you don't need SetDataHas given how you're using the list - since it just contains strings, and you don't need ±0 deduplication, you can use the simpler "If list does not contain value, then" formulation |
18:44 | <littledan> | thanks for explaining, bakkot |
18:47 | <bakkot> | (in whatwg's case they probably do end up needing to deal with specifying new types, since they have enough uses of user-exposed map-likes to justify it and they need to ensure those are all consistent, but if they'd stuck with lists of key/value pairs everywhere it would have been more obvious originally that iteration semantics weren't actually well-defined, instead of people just using the infra Map and assuming it was fully specified) |