Skip to content

Sort out comparisons and sorting #922

@AltGr

Description

@AltGr

As pointed for example in #917, we may need to clarify and implement ways of comparing elements.

Current situation

  • (In)equality is polymorphic, automatically expanded to recurse into structures and enums (but that code is quick&dirty, terrible on enums)
    • Comparing functions always returns true for equality (because that is most convenient in tests and assertions)
  • Comparisons are overloaded, and defined only for the base types
    • Comparison on durations can raise exceptions

Options and ideas

  • Just provide a list sort primitive with syntax,that takes the comparison operation as parameter
    (might be verbose)
  • Define a "canonical order" on everything, enabling comparison to be structurally expanded, like equality
    • Could be a lexical order on structs (by order of definition ? Alphabetical ?) and enums
  • Define the ordering using some attributes, or extra syntax in the type definition ? (e.g. #[sort.key = 1], #[sort.ignore] ?)
  • Define comparison functions manually, with an attribute expliciting that they are to be used for comparing the selected type
  • Other ideas ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions