5 ms·
Must support comparison for equality and the hash function. Default built-ins provided appropriately.
by andralex 12y ago
Must support comparison for equality and the hash function. Default built-ins provided appropriately.
- tel 12y agoOh, that's tragic.
- andralex 12y agos/tr/m/
- tel 12y agoVery magical—but I'm not convinced all types have meaningful equality or hashes. It's convenient to have, but thorny whenever you, say, have anonymous functions lying around.
- sanderjd 12y agoWhy is it tragic?
- dllthomas 12y agoMy read of this is that tel (mis)interpreted andralex as saying that all types must support equality and hashing, not that types must support equality and hashing to be hashable. It would be tragic because there can be types with no meaningful way to produce a hash or test for equality. If that's not the case, then I don't understand either.
- repsilat 12y agoIn theory you could use a tree for unhashable things with a total order, and you could use a list for just about anything else (though you might want to emit a warning...). I assume D has enough magic to pattern match on the traits of the types in the argument list?
- dllthomas 12y agoPresuming you have equality.