[Issue 8247] Inconsistent behaviour of randomSample depending on whether a random number generator is specified

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Jun 15 00:52:10 PDT 2012


http://d.puremagic.com/issues/show_bug.cgi?id=8247



--- Comment #4 from jens.k.mueller at gmx.de 2012-06-15 00:54:20 PDT ---
Now I see why you want to pass RNG by reference. Because you may want that two
functions share the same generator.
But then I would go with passing them all by reference for consistency reasons.
And all functions have as default argument rndGen() which could be renamed to
defaultRNG().
randomShuffle is already doing it this way. Though I don't see why it sets the
template argument RandomGen to Random by default. This should be inferred
automatically by the default argument rndGen() anyway.
So randomCover and randomSample should follow the same approach.

I do not see why one needs to pass a RNG by value then. Admittedly I have never
used std.random. So I may have wrong use cases in mind.
But having a thread local RNG that is used by default should be okay.

@Jonathan
Why should a RNG type have reference semantics? I think it's fine to pass them
by reference where needed.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list