--- Comment #6 from jens.k.muel...@gmx.de 2012-06-15 01:22:31 PDT ---
(In reply to comment #5)
> > Why should a RNG type have reference semantics? I think it's fine to pass
> > them
> by reference where needed.
> Because it makes no sense for it to have value semantics. Take this for
> auto func(R)(R r)
> auto var1 = r.front;
> auto var2 = generator.front;
> Both var1 and var2 will have the exact same value. This is an easy mistake to
> make, and since random number generators are supposed to be returning random
> numbers, having them return the _same_ number after popFront has been called
> definitely problematic.
> By making them reference types, the only time that you get the same number
> multiple times in a row is when you do it on purpose (e.g. by storing the
> of front or by calling save on the range).
> There's a discussion on this in issue# 7067.
I see. Thanks.
Since passing around RNGs should be by default by reference RNGs should be
reference types. Otherwise everybody writing own functions accepting RNGs has
to use ref which is error-prone.
Using ref when passing RNGs in std.random won't solve this general design
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------