On Thursday, July 16, 2015 at 12:25:01 PM UTC-4, Matt Bauman wrote:
>
> On Thursday, July 16, 2015 at 12:19:25 PM UTC-4, milktrader wrote:
>>
>> Also, back to the OP question, is the correct solution to simply define 
>>
>>  Base.hash(f::Foo) = f.x
>>
>
> No, I'd define Base.hash(f::Foo) = hash(f.x, 0x64c74221932dea5b), where I 
> chose the constant by rand(UInt).  This way it won't collide with other 
> types.  I really need to spend a bit more time with my interfaces chapter 
> and add this info there.
>

Gah, that won't work on 32 bit, sorry. The current idiom for this in base 
is something like:

const _foo_seed = UInt === UInt64 ? 0x64c74221932dea5b : 0x80783eb4
Base.hash(f::Foo) = hash(f.x, _foo_seed)

It'd be nice to make this easier.

Reply via email to