What is the use case of RandomCover?

Ivan Kazmenko gassa at mail.ru
Tue Feb 19 13:54:53 PST 2013


monarch_dodra wrote:
> void main()
> {
>     uint[5] arr1;
>     arr1[].fill(rndGen);
>     uint[5] arr2;
>     arr2[].fill(rndGen);
>     writeln("arr1: ", arr1[]);
>     writeln("arr1: ", arr2[]);
> }
> //----
> arr1: [3622200385, 2579361262, 3208046123, 1753759120, 
> 133131992]
> arr2: [3622200385, 2579361262, 3208046123, 1753759120, 
> 133131992]
> //----
> Oops!

Oops indeed!

It should be noted that a common need is to have reproducible RNG 
routines.  For example, I was angry at Python breaking the 
reproducibility of everything except the vanilla random.random() 
around version 3.2.  Still, as the language is going to have 
random2 anyway, and reproducibility will already suffer much from 
RNG becoming a reference type, it will be a good time for some 
cleanup.

On a side note, as D also uses MT19937 as the main RNG, random2 
designers may want to address the same accuracy issue which 
Python did.  More on that topic here: 
http://bugs.python.org/issue9025


More information about the Digitalmars-d-learn mailing list