Skip to content

Documentation: Clarify discriminant requirements #348

@vmiquel-42

Description

@vmiquel-42

The documentation of Language::discriminant says the following:

Type representing the cases of this language.
Used for short-circuiting the search for equivalent nodes.

Return the Discriminant of this node.

What properties must this discriminant uphold?

From a quick look at the code, I am inferring that it must:

  • Be compatible with Language::matches: if a.matches(b) then a.discriminant() == b.discriminant() (and not necessarily the reciprocal)
  • Be compatible with Ord: if a.discriminant() == c.discriminant() && a < b && b < c then a.discriminant() == b.discriminant()

Are there other requirements?

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