On Sunday, 15 May 2016 at 10:35:11 UTC, Basile B. wrote:
The "@disable this" is really a concern, because pointers have to be used (for example if the seed comes from a program option and that the gen is a global var then global var must be a pointer to the stuff).

I see that you are yourself affected by the issue because in the unittest you must take the gen address to use it in take .

The main consequence is that they are unsable in @safe code !

The @safe side of things is obviously a concern, but having @safe code is not very helpful if you don't also have _statistical_ safety. See what happens with phobos RNGs if you try,

    import std.stdio : writeln;
    import std.random : Random, unpredictableSeed
    import std.range : take;

    auto gen = Random(unpredictableSeed);

    gen.take(10).writeln;
    gen.take(10).writeln;

... ;-)

Probably the best way to handle this is to handle the take-the-address side of things by a @trusted wrapper that uses `return ref` to guarantee the pointer remains valid for the lifetime of the wrapper itself.
  • dxorshift: random numbe... Joseph Rushton Wakeling via Digitalmars-d-announce
    • Re: dxorshift: ran... Basile B. via Digitalmars-d-announce
      • Re: dxorshift:... Joseph Rushton Wakeling via Digitalmars-d-announce
        • Re: dxorsh... Joseph Rushton Wakeling via Digitalmars-d-announce
          • Re: dx... Joseph Rushton Wakeling via Digitalmars-d-announce
            • R... Basile B. via Digitalmars-d-announce
              • ... Joseph Rushton Wakeling via Digitalmars-d-announce
                • ... Basile B. via Digitalmars-d-announce
                • ... Joseph Rushton Wakeling via Digitalmars-d-announce
                • ... Joseph Rushton Wakeling via Digitalmars-d-announce
                • ... ag0aep6g via Digitalmars-d-announce
          • Re: dx... Joseph Rushton Wakeling via Digitalmars-d-announce
            • R... jmh530 via Digitalmars-d-announce

Reply via email to