Add isRandomNumberGenerator template #398

Merged
merged 4 commits into from Apr 7, 2012

Projects

None yet

2 participants

@jpf91
Contributor
jpf91 commented Jan 19, 2012

This adds a isRandomNumberGenerator template to std.random, which can be used to detect if a type is a random-number generator.

@andralex
Member

Odd naming convention, use Rng (or RandomNumberGenerator to avoid confusion with Range)

@andralex
Member
andralex commented Feb 5, 2012

We really need this but the question is whether seed() is enough of a distinguishing factor for RNGs, or we should have every RNG out there expose an explicit trait saying "yes, I am a RNG".

@jpf91
Contributor
jpf91 commented Feb 5, 2012

Thinking about this, some Rngs might not even have seed methods, at least those that would be based on /dev/random and /dev/urandom. So we should probably have isRandomNumberGenerator and isSeedable.

What's the best way to implement that 'trait'? A simple enum isRandom = true; as a member of every Rng?

@andralex
Member
andralex commented Feb 6, 2012

Yah, something like that but with "uniform" or "normal" in the name.

@jpf91
Contributor
jpf91 commented Feb 7, 2012

Should RandomSample and RandomCover also have that tag?

@andralex
Member
andralex commented Feb 9, 2012

I don't think RandomSample and RandomCover would need the tag. We need the isUniform tag to make sure e.g. we generate Gaussians from uniform distributions etc.

@jpf91
Contributor
jpf91 commented Feb 20, 2012

ping?

@andralex
Member

Hmmm, this does not have "uniform" in its name, which would lead to confusion. For example, one would expect that a Gaussian random number generator does satisfy isRandomNumberGenerator. Should we call it isUniformRNG or isUniformRandomNumberGenerator or isUniformRandom?

I think isUniformRNG is best, isUniformRandomNumberGenerator is too long. Should the 'RNG' part really be all uppercase this time?

@andralex andralex merged commit d2a605d into dlang:master Apr 7, 2012
@schveiguy schveiguy referenced this pull request in schveiguy/phobos Apr 15, 2012
Merged

std.process ready for review? #1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment