Earlier quoted context omitted.
> There are three key problems: finding a good way of hashing arbitrary data structures (or arbitrarily limiting the kinds of keys the map can store), finding a good way of determining equality of arbitrary data structures, and dealing with memory allocation semantics. It's not unheard of or unreasonable to have collections that have take an allocator as an argument. And a comparator and a hash function as arguments.…
Aye, we would have probably gone with a design similar to what you suggest... if we had generics, but we do not. Generics simply don't fit with the core values of the language. I still believe that there is room for languages without them.
struct cmp
{
hash: *fn(_:*void) u64,
eq : *fn(_:*void, _:*void) bool,
free: *fn(_:*void) void
}
With maybe some default options should be enough for at least the basics.
Note that the indirection overhead would be significant, but without generics or something similar, you don't really have a choice.