On Monday, 25 January 2016 at 23:37:25 UTC, Andrei Alexandrescu wrote:
On 01/25/2016 05:05 PM, Joseph Rushton Wakeling wrote:
One option would be to implement the basic RNG data structor à la C++,
as a functor

That's semantically the same as an input range. -- Andrei

“Yes, but...” :-P

There are actually some interesting subtleties required for the input range design, not just for RNGs but for ANY range whose elements are generated randomly.

I will try and write this up properly later, but the TL;DR is, it involves doing extra work to ensure every element is _truly_ lazily evaluated.

To some extent, splitting into functor and range wrapper can help clarify the code design there (even if the functor stays hidden as an implementation detail).

Reply via email to