# SE-0202 Amendment: Naming of the standard library random number generator

**URL:** <https://forums.swift.org/t/se-0202-amendment-naming-of-the-standard-library-random-number-generator/12155>\
**Category:** Pitches\
**Created:** [April 25, 2018, 8:30pm UTC](https://forums.swift.org/t/se-0202-amendment-naming-of-the-standard-library-random-number-generator/12155 "2018-04-25T20:30:54Z")\
**Posts on this page:** 1\
**Showing post:** 8

<div class="post-metadata">

**Author:** ![bzamayo](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/bzamayo/32/764_2.png) [@bzamayo](https://forums.swift.org/u/bzamayo)\
**Post date:** [April 26, 2018, 9:26am UTC](https://forums.swift.org/t/se-0202-amendment-naming-of-the-standard-library-random-number-generator/12155/8 "2018-04-26T09:26:26Z")

</div>

> [@Alejandro](#):
>
> I’m actually writing up another proposal to further increase functionality in RandomNumberGenerator which would require that some users have to interact with the generator itself, rather than a method take a generator. I don’t want to go too off topic here, but I imagine many others will write extensions onto RandomNumberGenerator to further increase functionality to fit their needs. Example:

The current proposal establishes a pattern of adding random-related convenience functions as extensions to instances or types. So `Random.default.fillBuffer(`) would be expressed as something like `Buffer.randomBytes(byteCount:using:)` at the type level or `buffer.randomizeBytes(using:)` on an instance. The `using` argument is optional, defaulting to the stdlib RNG's source. Why would this need to be inverted?

The idea that `Random` can act as a namespace is neat, but this intent is not described in the original proposal at all. If namespacing these types is worthwhile, then even so I would vote for some syntactic amendments. `Random` should be a enum (or a formal namespace declaration when we have one) and offer a static method like `default` which vends a `DefaultRandomNumberGenerator`. It doesn't really make sense to have a `Random` struct type also be the namespace.

If brevity is deemed a concern by many, `DefaultRNG` is still vastly superior to `Random` in my opinion. The abbreviation refers back to the name of the parent protocol, so I think the logical hierarchy is generally maintained. Still, I laid out my reasoning as to why I think character count is not of primary importance here.

(FWIW the idea that the standard library should host namespaces at all, with the expectation for others to extend it, is something that deserves discussion and not taken at face value. This isn't a common stdlib pattern today. When I read the original proposal, I was thinking that `Xorshift128RNG` (eg) and `DefaultRandomNumberGenerator` would simply sit alongside each other as top-level types.)

---

_[View the full topic](https://forums.swift.org/t/se-0202-amendment-naming-of-the-standard-library-random-number-generator/12155)._
