[Issue 7067] std.random.RandomSample and RandomCover are poorly designed

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Dec 6 08:04:52 PST 2011


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



--- Comment #5 from Vladimir Panteleev <thecybershadow at gmail.com> 2011-12-06 08:04:49 PST ---
The disadvantages of breaking backwards compatibility need to be considered on
a case-by-case basis. I think that turning RNGs into reference types has the
potential to be a relatively low-impact change, while also having a good chance
of revealing broken code.

The typical usage of std.random does not involve using the RNG types directly,
and rather using the implicit thread-local RNG.

An example of affected code:

Random r;
// ... use r

I think that generally allowing such code is a mistake, because it's not clear
that the RNG is not seeded.

auto r = Random(42);

We can implement this for backwards compatibility using static opCall (which
shall be scheduled for deprecation).

The biggest problem is intentional usage of value semantics (it would
transparently turn into reference semantics). Perhaps there's something we
could do with the help of opAssign?

-- 
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