Dconf 2015 talks...

Jonathan M Davis via Digitalmars-d digitalmars-d at puremagic.com
Mon Jan 25 10:40:59 PST 2016


On Monday, 25 January 2016 at 17:19:05 UTC, Joseph Rushton 
Wakeling wrote:
> On Monday, 25 January 2016 at 15:38:45 UTC, Era Scarecrow wrote:
>>  Hmm i wonder... If recognizes it as infinite, could it avoid 
>> treating them as forward ranges? As a struct it still wouldn't 
>> work, but as a class/reference type it would work then...
>
> They shouldn't be forward ranges anyway, because if their 
> content is randomly generated then it's not legit for them to 
> implement the .save property.  The whole implementation of 
> stuff in std.random via forward ranges is a massive design 
> mistake.

As long as the numbers are pseudo-random, then in theory, there's 
no problem with a range of random numbers being a forward range. 
That could be useful upon occasion (similar to how it can be 
useful that the same seed results in the same sequence of 
numbers). The problem is that if they're a forward range, then 
you tend to get code that accidentally ends up reusing numbers in 
the sequence and that definitely is a problem. So ultimately, 
they probably should be input ranges rather than forward ranges, 
but I think that it's more of an issue with human error than with 
what makes sense from a technical perspective.

Regardless, non-pseudo random number generators obviously can't 
be forward ranges though, since their state isn't savable or 
repeatable.

- Jonathan M Davis



More information about the Digitalmars-d mailing list