You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
aplavin opened this issue
Mar 2, 2024
· 2 comments
Labels
designDesign of APIs or of the language itselfequalityIssues relating to equality relations: ==, ===, isequalfeatureIndicates new feature / enhancement requestshashing
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.
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 think it would be great if this could be added to Julia. The first question would be if the maintainers are open to such an idea. The design would depend on the functionality one wants to implement. A very modest approach would be a macro defining ==, isequal and hash for a type T based on a list of fields that defaults to fieldnames(T). That wouldn't need much code.
designDesign of APIs or of the language itselfequalityIssues relating to equality relations: ==, ===, isequalfeatureIndicates new feature / enhancement requestshashing
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
The text was updated successfully, but these errors were encountered: