Mir Random [WIP]

Andrei Alexandrescu via Digitalmars-d digitalmars-d at puremagic.com
Wed Nov 23 11:16:29 PST 2016


On 11/23/2016 01:13 PM, Ilya Yaroshenko wrote:
> 1. Engine must not have implicit copy semantic: it is not correct for
> RNGs and has performance issues. They also should not be copied
> explicitly in this example.

OK, so (lack of) copyability is a good argument. I'm ready to live with 
random generators that are noncopyable values and use opCall; then use a 
range adaptor on top of a pointer to that. It seems providing the range 
primitives for a noncopyable object is not useful and is liable to 
create more confusion and frustration than a distinct API.

A tip for the range adaptor: have it allocate and own the generator 
internally. That way it's easy to make it reference counted economically.


Andrei


More information about the Digitalmars-d mailing list