Skip to content

Equality definition rough plan? #664

Open
@domenic

Description

@domenic

What is the issue with the Infra Standard?

See: #230, #643, #660, whatwg/html#10924, whatwg/html#10315

I think the following would work:

  • Define "equals" for all of Infra's primitive data types. Most are "obvious". Special notes:
    • Infra doesn't really define numbers, but we should call out that we intend mathematical equality by default
    • We already have a definition of "is" for strings
  • Disallow using "equals" on lists and maps, since it is too confusing.
  • Not 100% sure on the right path for structs, but my initial proposal:
    • Say that it works by default by comparing itemwise
    • Specifications can override the definition of "equals" for their particular struct (e.g. as URL does)
    • Note this means that structs containing lists do not work by default, hmm.
  • Say that every other type we use in specs defaults to "reference equality", but can define their custom equals overload if they want.
    • Examples of such types that are not just structs in disguise: algorithm steps, IDL values, JS values
  • With "equals" now defined for all types except lists and maps and things containing them, define "deep equals" for lists and maps, which recursively uses "deep equals" on keys/values/items
    • This can replace https://infra.spec.whatwg.org/#set-equal
    • If we think it's OK, per the above, for "equals" to not work on structs containing lists and maps, then we should define "deep equals" for structs.
      • It kind of sucks that you have to check if your struct recursively contains list and maps, before determining which operator to use? But maybe it's good for clarity?
  • Optionally define "shallow equals" for sets and maps, although I'm not sure we have any use cases
  • Go through existing places in Infra that use ambiguous notions of equality, like our definition of "list contains", and replace them to use "equals".

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions