Skip to content
This repository has been archived by the owner on Aug 18, 2023. It is now read-only.

Permit users to specify which fields are significant for hash and equality #27

Closed
gafter opened this issue Jun 15, 2023 · 2 comments
Closed

Comments

@gafter
Copy link
Member

gafter commented Jun 15, 2023

We have a number of comments in our code of the form

# TODO(NHD): @auto_hash_equals (currently can't b/c of existing hash that <something>)

If the user could specify which fields are significant, the hash and equality could be automatic. Perhaps something like this:

@auto_hash_equals (:name, :node_id) mutable struct Var <: Term
    name :: Id
    annos :: Annos
    node_id :: NodeId
end

/cc @NHDaly

@NHDaly
Copy link
Member

NHDaly commented Jun 29, 2023

cool! :) Thanks neal, sounds like a nice improvement.

@gafter
Copy link
Member Author

gafter commented Aug 9, 2023

This is now done.

@auto_hash_equals fields=(x, y) struct Point ... end

or, if you want the hash value cached,

@auto_hash_equals cache=true fields=(x, y) struct Point ... end

@gafter gafter closed this as completed Aug 9, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants