[Issue 10434] New: Don't use Random as template parameter name in std.random (or anywhere else)

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Jun 20 16:18:37 PDT 2013


http://d.puremagic.com/issues/show_bug.cgi?id=10434

           Summary: Don't use Random as template parameter name in
                    std.random (or anywhere else)
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: nobody at puremagic.com
        ReportedBy: joseph.wakeling at webdrake.net


--- Comment #0 from Joseph Rushton Wakeling <joseph.wakeling at webdrake.net> 2013-06-20 16:18:36 PDT ---
Quite a number of functions and objects in std.random use Random as the
template parameter name for a random number generator -- e.g. in RandomCover:

    struct RandomCover(Range, Random)
        if(isRandomAccessRange!Range && isUniformRNG!Random)

This is obviously dangerous as it risks accidental confusion with the alias
Random used for the default RNG type.

Elsewhere, the very long UniformRandomNumberGenerator is used as a typical
parameter name -- descriptive but a pain to retype!

So, I suggest replacing these parameter name with something consistent and more
appropriate -- either Rng (which is used in some other places in std.random) or
RNG (which I prefer to Rng, but which maybe isn't in line with D style:-)

If there's a desire to stress that a parameter is a _uniform_ random number
generator, we could also use Urng or URNG or even UniformRNG, but I think
that's overkill as those features of the parameter should be indicated by
template constraints, not naming conventions that are bordering on the
Hungarian.

We could also take this opportunity to standardize the typical variable name
for a RNG -- which in some places is called rnd, in some rng, in some urng, and
in some gen.

So, I propose standardizing on RNG or Rng for template parameters (someone tell
me which:-) and rng for variable names.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list