Skip to content

Convenient ways to define == and hash #53565

Open
@aplavin

Description

@aplavin

There are more and more packages that basically help users define ==/isequal/hash for their structs in a straightforward way – by forwarding to the struct fields.

A (potentially incomplete) list:
https://github.com/JuliaServices/AutoHashEquals.jl
https://github.com/jolin-io/StructEquality.jl
https://github.com/jw3126/StructHelpers.jl
JuliaRegistries/General#102035
Each is subtly different, all are in use! (aside from the last one, being registered)

I think this proliferation is a clear sign that Julia itself should provide "the definite" solution for this core problem.
A years-old discussion at #4648 focused on changing the default behavior, but that ship has sailed. So, there should be some simple opt-in for users.

I'm not too familiar with differences of those packages, only used https://github.com/jw3126/StructHelpers.jl a few times. Maybe, someone more knowledgeable can suggest a design that Base can use?

Pinging those who recently committed to those packages: @ericphanson @gafter @mcmcgrath13 @jw3126 @matthias314

Metadata

Metadata

Assignees

No one assigned

    Labels

    designDesign of APIs or of the language itselfequalityIssues relating to equality relations: ==, ===, isequalfeatureIndicates new feature / enhancement requestshashing

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions