You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is a _potential_ enhancement request.
A wrong D2 program:
import std.stdio, std.random;
void foo(RND)(RND rnd) {
foreach (i; 0 .. 5)
write(uniform(0, 10, rnd), " ");
writeln();
}
void main() {
auto rnd = Xorshift(1);
foo(rnd);
foo(rnd);
}
DMD 2.054 output:
3 1 2 7 5
3 1 2 7 5
The mistake is a missing ref, that causes foo to not return an updated random generator, so it always generate the same random values:
void foo(RND)(ref RND rnd) {
To avoid this bug (that I think is common enough), I suggest to experiment if it's performance-wide possibile to turn all random generators into reference things, that is final class instances, that don't require that "ref".
The text was updated successfully, but these errors were encountered:
bearophile_hugs reported this on 2011-09-02T02:30:49Z
Transfered from https://issues.dlang.org/show_bug.cgi?id=6593
CC List
Description
The text was updated successfully, but these errors were encountered: