Mir Random [WIP]

Andrei Alexandrescu via Digitalmars-d digitalmars-d at puremagic.com
Tue Nov 22 17:34:23 PST 2016


On 11/22/16 7:30 PM, John Colvin wrote:
> On Tuesday, 22 November 2016 at 23:55:01 UTC, Andrei Alexandrescu wrote:
>> On 11/22/16 1:31 AM, Ilya Yaroshenko wrote:
>>>  - `opCall` API instead of range interface is used (similar to C++)
>>
>> This seems like a gratuitous departure from common D practice. Random
>> number generators are most naturally modeled in D as infinite ranges.
>> -- Andrei
>
> I'm pretty sure everyone *wants* it to be a range, but it turns out it's
> a difficult design space. Lot's of nasty trade-offs that can be (and
> have been) argued back and forth depending on your priorities.

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.

> Perhaps you have an insight that has been missed that can make a good
> rng range without causing less than optimal performance or statistically
> unsafe default behaviour?

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

> IIRC you think people are making too much fuss about the statistically
> safe default behaviour, but it would be interesting to hear a more
> expanded version of that view.

I'm unclear on what that statistically unsafe default behavior is - my 
understanding is it has to do with RNGs being inadvertently copied. It 
would be great to formalize that in a well-explained issue.


Andrei



More information about the Digitalmars-d mailing list