pony-patterns
pony-patterns copied to clipboard
Add section about how to write value classes (including good hash functions)
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.