Reference semantic ranges and algorithms (and std.random)
monarch_dodra
monarchdodra at gmail.com
Tue Sep 25 09:36:21 PDT 2012
On Tuesday, 25 September 2012 at 16:15:24 UTC, Joseph Rushton
Wakeling wrote:
> On 18/09/12 17:05, monarch_dodra wrote:
>> As you can see from the ouput, that is not very random. That's
>> just the "tip of
>> the iceberg". *Anything* in phobos that iterates on a range,
>> such a fill,
>> filter, or whatever, will not advance the PRNG, arguably
>> breaking it.
>>
>> At best, a "global" PRNG will work, provided it is never ever
>> passed as an
>> argument to a method.
>
> Just to note, we already have an existing problem with this in
> Phobos, with the RandomSample functionality. See:
> http://d.puremagic.com/issues/show_bug.cgi?id=8247
Thank you for bringing it up. The problem is indeed as you said,
and making the PRNGs references types fixes it.
I have a pretty well developed first iteration. I hope that by
the end of next week, I'll have something to show.
Right now, I'm at a crossroad between:
*Inserting (requested) new features, (forced stack allocation,
pre-initialized ranges for performance)
*Strictly no new features, for an eventual (easier) breaking
change.
The problem with inserting "workaround 'features'", is that you
have to keep supporting even if it is not required anymore :p
More information about the Digitalmars-d
mailing list