On Mon, Jun 17, 2013 at 04:22:38PM -0400, Andrei Alexandrescu wrote: > On 6/17/13 3:32 PM, Joseph Rushton Wakeling wrote: > > > > ************************************************************************** > > * Reading multiple times from the start of the same random range, > > should * > > * produce different (and statistically independent) results each time. > > * > > > > ************************************************************************** > > I don't think that's a good rule. > > A range that does that should be an input range, not a forward > range. Calling .save on a random range and tracing the steps again > should produce the same values. [...]
Yeah, if a range encapsulates a non-repeatable RNG (e.g., a "true" RNG that, say, reads environmental variables to randomize its output, or reads from a hardware RNG), then it should be an input range. Such ranges cannot have any meaningful .save semantics, so they should not be forward ranges. OTOH, one of the main issues in the current std.random is that RNGs are implemented as pass-by-value structs, which is a bad choice IMO. If we change them to have reference semantics instead, many of these issues would be solved. T -- 2+2=4. 2*2=4. 2^2=4. Therefore, +, *, and ^ are the same operation.