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

Yes, I think this is avoiding the existing problems with RNGs and ranges rather than solving them.

I don't blame anyone for _wanting_ to avoid them; they are nasty, subtle issues that seem to keep getting more complex the more one looks at them (for example, after my DConf talk last year, I realized that there were a whole set of other potential complications related to how ranges typically treat laziness). But I think they can be solved, and should be.

OTOH, there's no reason per se why there should not be an `opCall` for random number generators along the lines of,

    UIntType opCall()
    {
        this.popFront();
        return this.front;
    }

... just to provide options to the user. (BTW, note the order there, which touches on the issues related to what lazy evaluation means not just for RNGs but for any non-deterministic IO.)

Reply via email to