default random object?

bearophile bearophileHUGS at lycos.com
Fri Feb 13 17:52:47 PST 2009


Andrei Alexandrescu:
> Leaving normal() aside (does your implementation implement the ziggurat 
> algorithm?

You can use two well known algorithms, one is a simple one, and the other is more precise. The simple one is just to extract 10 or 12 uniform numbers and sum them.


> I don't see how having to memorize four names instead of one is necessarily 
> awesome and beautiful. Besides uniform() renders "random" redundant. 
> Hardly a pinnacle of good API design

You never need this, so it's over-generalized, and it's also ugly to see and noisy too:
uniform!("(]")(rng, a, b);

Those names are almost self-explaining, you don't need much time to remember them. And each one of them represent a very common operation you too want to do. Of course your tastes can be different from mine (and Python ones too).

When the phobos of D2 will be "finished" it will require one year or more of "tuning" (discussing names here on the newsgroup) to find the best names, API, etc.

While we are discussing Phobos, I'd also like to have a lazy prime generator, prime tests a binomial, etc. Such things are useful in many programs (you can find them all in my dlibs, but that hyperfast lazy prime generator is GNU, unfortunately).

Bye,
bearophile



More information about the Digitalmars-d mailing list