hap.random: a new random number library for D

Joseph Rushton Wakeling via Digitalmars-d-announce digitalmars-d-announce at puremagic.com
Tue Jun 10 13:51:22 PDT 2014


On Tuesday, 10 June 2014 at 11:32:54 UTC, bearophile wrote:
> So can you can generate random values in strongly pure 
> functions with this? You can allocate the RNG class inside the 
> function... If that's right, then is this simple strongly pure 
> random generator worth adding to std.random2?

Forgive me if I'm missing something obvious, but as it stands I 
don't see how the R250/521 algorithm you pointed me to can be 
strongly pure.  As it's defined in the link you pointed me to, 
it's accessing (and updating) global mutable state.

It would surely be possible to define it to take as input 
constant buffers, and to return constant buffers, which ought to 
allow purity -- but wouldn't that be a memory allocation 
nightmare?

Can you clarify what you're thinking of here it terms of D's 
strong purity?


More information about the Digitalmars-d-announce mailing list