www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 5441] New: std.random.rndGen always returns Random.

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5441

           Summary: std.random.rndGen always returns Random.
           Product: D
           Version: unspecified
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: Phobos
        AssignedTo: andrei metalanguage.com
        ReportedBy: repeatedly gmail.com



09:43:40 PST ---
Created an attachment (id=867)
Patch for this suggestion

rndGen always returns Random(usually MT) object. This is often useful, but
randomShuffle cant't take other random generators.

I think following signature is better.

    ref RandomGen rndGen(RandomGen = Random)()

But this change forces us to write parenthesis function call.

    rndGen;    // Compilation error
    rndGen();  // OK, return Random object.

For me, this is no problem. However I don't know the writing style of other
people.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 10 2011
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5441


Stewart Gordon <smjg iname.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |smjg iname.com




 Created an attachment (id=867) [details]
 Patch for this suggestion
 
 rndGen always returns Random(usually MT) object. This is often useful, but
 randomShuffle cant't take other random generators.
It can, as of DMD 2.058 at least. Its signature is void randomShuffle(Range, RandomGen = Random)(Range r, ref RandomGen gen = rndGen) The two parameters are the range to shuffle and the RNG to use to perform the shuffle.
 I think following signature is better.
 
     ref RandomGen rndGen(RandomGen = Random)()
What, exactly, would your rndGen function _do_ to the RandomGen object you pass into it??? -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Apr 08 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5441


bearophile_hugs eml.cc changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bearophile_hugs eml.cc



See also Issue 4851

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Apr 08 2012
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5441


Joseph Rushton Wakeling <joseph.wakeling webdrake.net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |joseph.wakeling webdrake.ne
                   |                            |t



2013-05-03 07:38:00 PDT ---
rndGen _should_ always return Random, because rndGen is intended to provide a
thread-safe instance of the default RNG type (which _is_ Random).

The problems identified here aren't with rndGen but with code that does not
take into account RNG instances other than rndGen.  So, I suggest this bug be
marked as invalid.

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