Open paulie-g opened 9 years ago
... and it becomes clear from reading the code that \@with_cmp makes .hash() behave in the exact way needed to satisfy this use case. Perhaps a mention of this in the docs might be useful?
I'm traveling right now but for now is like to mention characteristic's fork hynek/attrs that does hash separately because I ran into frequent problems with mutable members.
(I'll look at your PR once I'm back)
Thanks for the pointer, I'll be using attrs from now on. It's got a number of small improvements, but there are so many that it adds up to a big difference in usability and elegance. As far as mutable members interacting with hashes goes, that's expected. There are several ways of dealing with that edge case, but none are general enough imo to make them foolproof, so I'd say leaving the burden with the user is acceptable there.
The pull request is just a doc change, no hurry there.
Heh yeah, attrs is born out of my own frustrations with characteristic; hence that effect. :)
I have run into this use case a few times now: I want all of characteristic's goodness for the entire set of attributes, but it only makes sense for .hash() to reference some subset of of them, because the rest are not meaningful in that context. Characteristic already has a facility to make this distinction for compares (with_cmp/exclude_from_cmp) and I'd like to submit a PR that does it for hashes as well in an analogous manner.
Any objections @hynek ? :+1: