Last update November 29, 2007

Doc Comments / Phobos /
Std Random



std.random    

Table of contents of this page
std.random   
Comments   
Comparing D's std.rand with C's rand   
Shared Seed State   
Links   

Comments    

Add your comments here...

Comparing D's std.rand with C's rand    

D's std.rand is slower than C's rand, but it's more random.

Shared Seed State    

By the looks of the documentation - haven't checked the code - the std.random module shares a single seed state.

IMO this is wrong. What if one wanted to conduct several repeatable tests concurrently - perhaps because the measured aspects were running in multiple threads?

It should be rewritten as a class, as in:

    class Random
    {
    public:
        this(uint seed, uint index);
        this();

public: uint rand();

// Implementation . . . }

Also, why not use provide extensed sized random values, e.g. 64-bits, perhaps combining 2 successive uints into a ulong? Sure, it can be done in client code, but better to have it done once only in Phobos.

(from NG:digitalmars.D.bugs/834)

Links    


FrontPage | News | TestPage | MessageBoard | Search | Contributors | Folders | Index | Help | Preferences | Edit

Edit text of this page (date of last change: November 29, 2007 20:06 (diff))