Random
is the type of the default random number generator, it is not a "namespace" (that any type can be said to be a namespace, depending on how you define the word namespace, doesn't change anything).
Looking at the generated interface and documentation:
public struct Random : RandomNumberGenerator {
/// The default instance of the `Random` random number generator.
public static var `default`: Random
...
}
It is clear that Random
is a RandomNumberGenerator
and it has a static property called default
which is of type Random
because it is "The default instance of the Random
random number generator" exactly like its documentation says.
This thread will be confusing and unproductive if we cannot even agree that what is currently named Random
is the type of the default RandomNumberGenerator
.
I think it is important to note that for truly random, non-repeatable RNGs like Random
it doesn't make sense to create instances, hence the private initializer and a single instance being available as a static default
property of Random
. But this is in contrast to PRNGs, for which it doesn't make sense to not being able to explicitly create instances.
So, the way I see it, the only reason why Random
prevents initialization (by having its only init being private) is that it happens to be an RNG and not a PRNG (for good reasons). If Random
had been a PRNG, it would have had a public initializer, probably one init(seed: UInt64)
and one init()
which would use a truly random seed.
My point is that the inability to create instances of Random
should not be taken as a hint of it being kind of like a "namespace" for various random stuff, in addition to being the type of the default random number generator. I think it would be a mistake to have the same type taking on both these very different roles.
So if there is a need for this namespace-thing, then it should not be conflated with anything else (including the type of the default random number generator), and it should probably be called Random, because Random would be a good name for such a namespace-thing.
I agree with the core team and others that Random
is not a good name for the type of a (default) random number generator, that it is misleading, and that it should be renamed to DefaultRandomNumberGenerator
(or DefaultRNG or something else that says what it is), which would also free up the name Random for the hypothetical namespace-thing, if that turns out to be something that is really needed and sensible.
The documentation of DefaultRandomNumberGenerator
should be clear up front about its intended use, or rather non-use, in the common case, so that users see why they never should have to write it out explicitly unless they really have to.