Compile-Time RNG

Stefan Koch uplink.coder at googlemail.com
Thu Mar 7 13:51:58 UTC 2019


On Thursday, 7 March 2019 at 09:53:58 UTC, Joseph Rushton 
Wakeling wrote:
> On Tuesday, 5 March 2019 at 22:57:31 UTC, Stefan Koch wrote:
>> it's easy. you use the time_stamp at compilation which is 
>> expressed as a certain lexer variable. you parse that at ctfe 
>> and use it as the seed for another random number gen.
>
> Depending on the use case, that might be problematic.  Consider 
> two different compilation units issued in the same second (so 
> same timestamp).  Both use the CTFE RNG, and because their seed 
> is the same, so is the pseudo-random sequence.

Using that in any way that's not a toy example is ill'advised. 
I'd say :)



More information about the Digitalmars-d mailing list