www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 5883] New: std.random.dice() without rnd generator

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

           Summary: std.random.dice() without rnd generator
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: Phobos
        AssignedTo: nobody puremagic.com
        ReportedBy: bearophile_hugs eml.cc



This is the online documentation of std.random.dice() (DMD 2.052) (note the
missing rnd generator agument):
http://www.digitalmars.com/d/2.0/phobos/std_random.html#dice

auto x = dice(0.5, 0.5);   // x is 0 or 1 in equal proportions
auto y = dice(50, 50);     // y is 0 or 1 in equal proportions
auto z = dice(70, 20, 10); // z is 0 70% of the time, 1 30% of the time,
                           // and 2 10% of the time


But this generates several compile bugs:

import std.random;
void main() {
    dice(0.5, 0.5);
}


While this compiles and runs:

import std.random;
void main() {
    auto rnd = Xorshift(1);
    dice(rnd, 0.5, 0.5);
}


This looks like a documentation bug, but I prefer to see it as an enhancement
request.


See also issue 5849

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Apr 24 2011
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5883


David Simcha <dsimcha yahoo.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |dsimcha yahoo.com
         Resolution|                            |FIXED



This was fixed a while back in Git and will be in the next release.  (Thanks,
Andrei.)

https://github.com/D-Programming-Language/phobos/commit/1083bd4e7b4ef0475084d7eab2e67c65e511c3d4

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