
Ingvar <ingvar@hexapodia.net> writes:
Chris Dean writes:
Why does genhash use the technique of registering hashing functions and equality predicates instead of using keyword parameters?
Primarily so that a "sufficiently clever" implementation can go forth and analyse the hash function and equality test predicate at time of registration and possibly construct custom classes and methods for it.
Secondarily, to reinforce the coupling between an equality test predicate and a hash function.
I see, thanks. For me, -1 for this idea. While it's a worthwhile goal to couple these two concepts it seems more complicated than just providing keyword parameters. Keywords have the obvious downside of the user mismatching the test and hash, but I believe this is outweighed by the simplicity of the design. Certainly either position is subject to some debate! One thing I like about the keyword design is that if a user prefers the registration design, then she can implement it herself on top of the keyword design. The reverse (implementing the keyword design on top of the registration design) is more difficult or has some performance implications. Cheers, Chris Dean