www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - std.digest

reply =?UTF-8?B?TcOhcmNpbw==?= Martins <marcioapm gmail.com> writes:
Hi!

To my surprise, std.digest.MurmurHash3 doesn't work in CTFE.

Would it be hard to have it explicit in the documentation if a 
particular Phobos symbol works in CTFE? Maybe it could be manual, 
and vote-based, to avoid building infrastructure around it.

Also, MurmurHash3 only outputs 32-bit or 128-bit hashes, which 
leaves us without any modern fast 64-bit digest. Would anyone 
oppose pulling an XXHash implementation into Phobos?
Oct 17 2018
parent reply rikki cattermole <rikki cattermole.co.nz> writes:
On 17/10/2018 10:36 PM, Márcio Martins wrote:
 Hi!
 
 To my surprise, std.digest.MurmurHash3 doesn't work in CTFE.
 
 Would it be hard to have it explicit in the documentation if a 
 particular Phobos symbol works in CTFE? Maybe it could be manual, and 
 vote-based, to avoid building infrastructure around it.
It uses a union, that is why it doesn't work at CTFE. Hopefully newCTFE can solve that one.
 Also, MurmurHash3 only outputs 32-bit or 128-bit hashes, which leaves us 
 without any modern fast 64-bit digest. Would anyone oppose pulling an 
 XXHash implementation into Phobos?
A better question is why doesn't it support 64bit?
Oct 17 2018
parent Stefan Koch <uplink.coder googlemail.com> writes:
On Wednesday, 17 October 2018 at 09:43:16 UTC, rikki cattermole 
wrote:
 It uses a union, that is why it doesn't work at CTFE. Hopefully 
 newCTFE can solve that one.
unions work at ctfe. it's type punning using unions which does not work. And there are no plans to support that at newCTFE, since it invokes platform-dependent behavior. It is a pretty bad idea include non-standardized platform-dependent-behavior when forming literals.
Nov 22 2018