Ranges and random numbers -- again

H. S. Teoh hsteoh at quickfur.ath.cx
Mon Jun 17 13:00:56 PDT 2013


On Mon, Jun 17, 2013 at 08:32:14PM +0100, Joseph Rushton Wakeling wrote:
> Hello all,
> 
> I think my last post on this topic may have been too convoluted, so
> here's another go.  The goal here is to try and derive some
> well-defined strategies for designing ranges that make use of random
> number generators.
> 
> The purpose of this first email is to justify what I think should be
> the first basic rule of random ranges [that is, ranges where
> popFront() makes use of random or pseudo-random numbers to generate
> the new value of front()].  That rule is:
> 
>     **************************************************************************
>     * Reading multiple times from the start of the same random range, should *
>     * produce different (and statistically independent) results each time.   *
>     **************************************************************************
[...]

I understand your reasons for choosing this rule, but I feel a bit
uneasy about it. Under this rule, RNGs would produce their entire random
sequence just by accessing .front multiple times, which violates the
standard range behaviour of .front not changing until you call
popFront().

Is it possible to arrange it so that the ctors behave as though
popFront() were called at the end? (I say "as though" because there are
some cases for which this shouldn't actually happen, like when there's a
finite permutation sequence involved.)


T

-- 
Latin's a dead language, as dead as can be; it killed off all the Romans, and now it's killing me! -- Schoolboy


More information about the Digitalmars-d mailing list