Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add section about how to write value classes (including good hash functions) #34

Open
mfelsche opened this issue Dec 14, 2018 · 0 comments

Comments

@mfelsche
Copy link

Value classes are classes that serve as (mostly immutable) containers for 1 or more values (their fields).

To make them actually usable with pony, they need to be Equatable (e.g. for pattern matching on value), Comparable if you want to sort or compare them, Hashable, if you want to put them in a Map, Stringable for printing etc.

It is especially tricky how to write good hash functions. This section should include a suggestion/recipe on how to write good hash functions in pony. E.g. Equality and Hash values should match up, in that eaual things must have the same hash value.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant