On 08/05/14 19:18, Nick Sabalausky via Digitalmars-d wrote:
Some good looking stuff in there. The separation is a nice improvement, and
having a "shuffle" is something we could certainly use.

Thanks! :-)

There is already a shuffle function in the existing std.random, but it's called randomShuffle:
http://dlang.org/phobos/std_random.html#.randomShuffle

About avoiding problems from accidentally duplicating internal state, I'm not
sure that changing to classes is really necessary for that. I addressed it in
HashDRBG by simply making the internal state static. (Oops, or at least I meant
to...fixing now...). The various InputRange instantiations (for the different
possible elemement types) all draw from the same source (HashDRBGStream), so
this should work out pretty well. I'd imagine the existing std.random algos
could do something similar.

That seems a problematic fix for me -- doesn't it mean that there can only ever be one instance of any individual RNG? While many applications wouldn't notice the difference, it's a pretty major breach of encapsulation (and purity).

On a related note -- I like your concept of a random stream. I think it may be useful to adapt as part of the way in which std.random2.device works. I need to compare to other Phobos stream code -- isn't Steven Schweighoffer working on up-to-date stream functionality as part of std.io ... ?

Reply via email to