1st draft of complete class-based std.random successor

Joseph Rushton Wakeling joseph.wakeling at webdrake.net
Wed Mar 19 17:15:21 PDT 2014


On Thursday, 20 March 2014 at 00:05:20 UTC, Joseph Rushton 
Wakeling wrote:
> Not really.  There's still usable functionality in there for 
> all architectures (although I'm not sure how practically 
> useful).

Just to expand on that remark: my impression is that individual 
random devices are inevitably going to be architecture-dependent. 
  /dev/random and /dev/urandom are Posix devices; Windows AFAIK 
has its own alternative.  So the broad idea is that you'd have as 
much generic functionality as possible available to all 
architectures (mostly related to what sources you read from; a 
file, a socket, something else?), and then individual 
architecture-dependent aliases would map this to particular 
random sources available to them.

Then, finally, you'd have some default alias RandomDevice that 
would point to an appropriate architectural default; so e.g.

     version (Posix)
     {
         alias RandomDevice = DevURandom!uint;
     }
     else version (Windows)
     {
         alias RandomDevice = ...
     }
     // etc.

... so, unless you were quite specific about your requirements, 
90% of the time you could just use RandomDevice and expect it to 
Just Work whatever your platform.

But as random devices are not my strongest area of expertise, 
I'll happily take advice here.


More information about the Digitalmars-d-announce mailing list