Mir Random [WIP]

Ryan via Digitalmars-d digitalmars-d at puremagic.com
Wed Nov 23 07:43:16 PST 2016


On Wednesday, 23 November 2016 at 15:29:14 UTC, Kagamin wrote:
> On Wednesday, 23 November 2016 at 14:30:53 UTC, Andrei
>
> Consider this okayish looking code:
> consume(rng());
> consume(rng.take(2)); //reuses previous value
> consume(rng()); //discards unused value

Also consider the case of using 1 generator in your program, but 
calling it from different places. In one place, you use opCall 
with the popFront -> front order of calls, and in the other you 
use the range interface directly with the order reversed. You 
would re-use values there too.

By offering both interfaces together it makes it pretty easy to 
create silly bugs like this, especially in a large project.

Might be useful to have a basic RNG interface and then wrap it 
with a template that provides either, but not both, of the other 
interfaces at a time.




More information about the Digitalmars-d mailing list