Tuple enumeration without integers or strings

Paul Backus snarwin at gmail.com
Sun Jan 3 04:16:20 UTC 2021


On Sunday, 3 January 2021 at 02:41:12 UTC, Paul wrote:
>
> I haven't used hashOf before, though assuming no  equal values, 
> which I generally wouldn't do, I take it this is reliable? I 
> haven't tried it before, and I dont know how to effectively 
> compare it to using 'switch(w.to!string)' & 'case 
> Wind.B.stringof' (regarding speed/reliability).

hashOf is not guaranteed to produce unique values, so I would not 
advise using it here.

to!string is expensive both at compile time (requires a lot of 
template instantiations) and runtime (needs to allocate memory 
for the string). It will work if you need to hack something 
together quickly, but I would not recommend it for "serious" code.


More information about the Digitalmars-d-learn mailing list