News for hackers. Stuff that matters.
Re:Hidden treasure in the D standard library by tel on Thursday August 28, 2014 @04:17PM (#8239465)
How do you know what types are hashable?
Re:Hidden treasure in the D standard library by andralex on Thursday August 28, 2014 @04:43PM (#8239594)
Must support comparison for equality and the hash function. Default built-ins provided appropriately.
Re:Hidden treasure in the D standard library by repsilat on Friday August 29, 2014 @04:19AM (#8241596)
In 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?

Re:Hidden treasure in the D standard library by dllthomas on Friday August 29, 2014 @12:37PM (#8243253)
Presuming you have equality.
Re:Hidden treasure in the D standard library by tel on Thursday August 28, 2014 @04:54PM (#8239645)
Oh, that's tragic.
Re:Hidden treasure in the D standard library by andralex on Thursday August 28, 2014 @05:41PM (#8239869)
s/tr/m/
Re:Hidden treasure in the D standard library by tel on Thursday August 28, 2014 @05:54PM (#8239935)
Very 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.
Re:Hidden treasure in the D standard library by andralex on Thursday August 28, 2014 @06:12PM (#8240018)
Those won't compile.
Re:Hidden treasure in the D standard library by tel on Thursday August 28, 2014 @07:52PM (#8240413)
Oh, dlthomas caught what went wrong! I misunderstood, apologies. If they dont compile then that's great.
Re:Hidden treasure in the D standard library by sanderjd on Thursday August 28, 2014 @07:20PM (#8240273)
Why is it tragic?
Re:Hidden treasure in the D standard library by dllthomas on Thursday August 28, 2014 @07:28PM (#8240305)
My 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.