www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 10265] New: RandomSample fails when passed an InputRange as input

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

           Summary: RandomSample fails when passed an InputRange as input
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: nobody puremagic.com
        ReportedBy: joseph.wakeling webdrake.net


--- Comment #0 from Joseph Rushton Wakeling <joseph.wakeling webdrake.net>
2013-06-04 06:23:21 PDT ---
By design, RandomSample is supposed to operate on any InputRange:

    struct RandomSample(R, Random = void)
        if(isInputRange!R && (isUniformRNG!Random || is(Random == void)))

However, RandomSample itself is designed to be a ForwardRange with save()
defined.  The save property in turn assumes that the input has save() defined:

     property typeof(this) save()
    {
        auto ret = this;
        ret._input = _input.save;
        return ret;
    }

The assumption that RandomSample can have save() defined is also problematic
for a second reason: the output from the saved copy will depend on random
numbers, and therefore will not be identical, so it is not clear what the
benefit of a save() function is.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jun 04 2013
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10265



--- Comment #1 from Joseph Rushton Wakeling <joseph.wakeling webdrake.net>
2013-06-04 10:42:05 PDT ---
Fix submitted: https://github.com/D-Programming-Language/phobos/pull/1332

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jun 04 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10265



--- Comment #2 from github-bugzilla puremagic.com 2013-06-07 12:06:31 PDT ---
Commits pushed to master at https://github.com/D-Programming-Language/phobos

https://github.com/D-Programming-Language/phobos/commit/cbdd14b57b41092d4e75dc11338b14c9d61ebd9e
Issue 10265 - RandomSample fails when passed an InputRange as input

 * Issue fixed by making presence of save() property conditional
   on input being a ForwardRange.

https://github.com/D-Programming-Language/phobos/commit/783902cafb17eed755d185f63ea2bafa63e4f387
Merge pull request #1332 from WebDrake/randomsample-save

Issue 10265 - RandomSample fails when passed an InputRange as input

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jun 07 2013
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10265


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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED


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