Compile-Time RNG

Stefan Koch uplink.coder at googlemail.com
Tue Mar 5 22:57:31 UTC 2019


On Tuesday, 5 March 2019 at 21:22:55 UTC, Cym13 wrote:
> On Wednesday, 20 January 2016 at 23:21:04 UTC, CTRNG wrote:
>> I managed to create a compile-time random number generator.
>>
>> Proof of concept, with some explanatory comments: 
>> http://dpaste.dzfl.pl/668646ce6d71
>>
>> Just thought this might be of interest to some of you here.
>
> Sorry for necroposting but does anyone have that POC? 
> dpaste.dzfl.pl seems down.
>
> I'm currently facing a case where I would very much like to 
> have random data at compile-time and I can't find a way to get 
> them.
>
> Also the core.bitopt.bsf bug mentionned later in the thread was 
> fixed so no luck there (and the bug report is still open, I 
> think it should be closed).

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.


More information about the Digitalmars-d mailing list