Issue 19168 - std.random.randomCover and randomSample should warn that struct RNGs are copied (original is not updated)
Summary: std.random.randomCover and randomSample should warn that struct RNGs are copi...
Status: NEW
Alias: None
Product: D
Classification: Unclassified
Component: phobos (show other issues)
Version: D2
Hardware: All All
: P3 normal
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-08-14 11:03 UTC by Nathan S.
Modified: 2024-12-01 16:34 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Nathan S. 2018-08-14 11:03:07 UTC
The behavior is described in https://issues.dlang.org/show_bug.cgi?id=7067. Since the `rng` parameter is `auto ref` this behavior is not obvious merely from the function signature, so at the very least this quirk should be mentioned in the documentation.
Comment 1 Seb 2018-08-15 13:22:08 UTC
Better ways:

- split in two overloads and deprecate the by value one
- fix random ranges in general by making them non-copyable (like suggested in #7067)

However, the latter is a lot of work and it might be easier to just submit a version of mir.random as std.experimental.random and to fully replace std.random (there has been some talk about doing this, but it never materialized.)
Comment 2 dlangBugzillaToGithub 2024-12-01 16:34:05 UTC
THIS ISSUE HAS BEEN MOVED TO GITHUB

https://github.com/dlang/phobos/issues/10347

DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB