A strongly pure PRNG

Joseph Rushton Wakeling joseph.wakeling at webdrake.net
Wed Jan 8 02:32:07 PST 2014


On 08/01/14 02:13, deadalnix wrote:
> Without this, http://dilbert.com/strips/comic/2001-10-25/

I guess you could do a design where you pass an immutable RNG state, and you get 
back whatever random number you ask for plus a new immutable state (perhaps 
provided via an out parameter).  It's just that in this case it puts the 
responsibility on the user to be really careful in ensuring that the RNG state 
is passed around properly (the main PITA being getting back the updated state 
rather than passing the current one).

It's really much easier to do it as a class which updates internal state, and 
where you can apply @safe pure nothrow and (with obvious exceptions) const to 
just about every method; and I don't really see what you lose in a practical 
sense by doing it this way.


More information about the Digitalmars-d mailing list