Not-so-unpredictable seed?
jerro
a at a.com
Tue Apr 17 22:27:20 PDT 2012
On Wednesday, 18 April 2012 at 05:05:20 UTC, Joseph Rushton
Wakeling wrote:
> On 18/04/12 06:43, jerro wrote:
>> According to the comment the call to prime() is necessary
>> so that the result doesn't always start with the same element.
>> But prime() uses the gen member which is only assigned after
>> the
>> constructor completes. So at the time when prime() is called
>> the
>> gen member is in some default state, so the prime() call in the
>> constructor always does the same thing. The fix would be to
>> either modify the constructor to take random generator as a
>> parameter if Random type parameter is not void, or to move the
>> call to prime() out of constructor and into all the
>> randomSample
>> functions. In the ones that have a random generator parameter,
>> the call to prime should come after gen is asigned.
>
> Ahhh, clear. I should have worked that out from the code,
> brain not working right today. :-P
>
> It still looks like a serious bug to me, so I've filed a report.
> http://d.puremagic.com/issues/show_bug.cgi?id=7936
Well, off course it's a bug :D. I opened a pull request:
https://github.com/D-Programming-Language/phobos/pull/542
More information about the Digitalmars-d-learn
mailing list