Mir Random [WIP]

Martin Nowak via Digitalmars-d digitalmars-d at puremagic.com
Fri Nov 25 22:46:19 PST 2016


On Wednesday, 23 November 2016 at 01:34:23 UTC, Andrei 
Alexandrescu wrote:
> On 11/22/16 7:30 PM, John Colvin wrote:
>> On Tuesday, 22 November 2016 at 23:55:01 UTC, Andrei 
>> Alexandrescu wrote:
> The proposed design has disabled copy ctor and uses opCall() 
> for a new element. That seems to be a difference without a 
> distinction from an input range that has disabled copy ctor and 
> offers the input range primitives.

Yes the problems are inadvertent copies and a disabled this(this) 
would prevent that. RNGs should have unique ownership of their 
internal state.
Using InputRanges with phobos is somewhat clumsy. Maybe people 
have been burned by those and now generally consider InputRanges 
as broken.
Maybe non-copyability needs to become a requirement for 
InputRanges.

> We should add a reference RNG that transforms any other RNG 
> into an input range that shares the actual RNG.

We already have refRange for that, no?
Also refCounted(Random(unpredictableSeed)) should work.


More information about the Digitalmars-d mailing list