13 Jun
2015
13 Jun
'15
8:24 p.m.
Paul Fultz II
The problem with this approach is that equality of keys can't be more general than type identity.
Instead a special "hash"-like function could be provided that would transform the keys to a type where identity could be used. This might be faster than using linear/binary search, since the the compiler can do the lookup based on identity.
I have thought about that already, but how would you define such a hash function for _heterogeneous_ objects? I just don't know how that can be done, but it is not a bad idea. Still, I think a good compile-time performance is achievable without a hash function, by simply avoiding the short-circuiting in the `contains` function. Regards, Louis