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

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Jun 20 16:27:57 PDT 2013


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



--- Comment #16 from Joseph Rushton Wakeling <joseph.wakeling at webdrake.net> 2013-06-20 16:27:56 PDT ---
(In reply to comment #15)
> Why do you/we care so much for breaking backwards compatibility with something
> that is so broken? If you let it take the generator by ref I think you will
> remove from bugs from user code.

You can pass the generator to the constructor by ref, but you can't safely
store it as a reference type, and so far as I can see you DO need to store it
internally -- RandomCover is a range object, not a function where you can just
use it and return.

_If_ you could safely store a reference to the RNG, then of course what you say
would be right.  But you can't, not while they are value types.

My proposal won't break backwards compatibility (which is not in itself a good
thing -- this back deserves to be broken:-) and won't fix the bigger picture,
but it will improve the status quo without having to wait for the large-scale
redesign that random number generation needs.

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