default random object?

Christopher Wright dhasenan at gmail.com
Sat Feb 14 05:55:08 PST 2009


Andrei Alexandrescu wrote:
> auto rng = Random(unpredictableSeed);
> auto a = 0.0, b = 1.0;
> auto x1 = uniform!("[]")(rng, a, b);
> auto x2 = uniform!("[)")(rng, a, b);
> auto x3 = uniform!("(]")(rng, a, b);
> auto x4 = uniform!("()")(rng, a, b);

I always have to look up whether "[]" is exclusive or inclusive. It's 
succinct, but you only have to write code once, and you have to read it 
often.

Granted, people who are more math-intensive than I can read that without 
thinking about it, but the preponderance of programmers have no more 
math skills than I.

So, might I suggest using an enum rather than a string mixin?



More information about the Digitalmars-d mailing list