dxorshift: random number generators from the extended Xorshift family

Basile B. via Digitalmars-d-announce digitalmars-d-announce at puremagic.com
Sun May 15 03:35:11 PDT 2016


On Sunday, 15 May 2016 at 09:20:22 UTC, Joseph Rushton Wakeling 
wrote:
> http://code.dlang.org/packages/dxorshift
> https://github.com/WebDrake/dxorshift
>
> [...]
>
> The generators are all implemented as structs, but in order to 
> prevent some known problems with unintended copy-by-value of 
> RNGs, the postblit has been disabled.  For similar reasons, 
> these generators are implemented as input ranges, not forward 
> ranges, so that library functionality cannot copy generator 
> state under the hood.
>
> `dup` properties are however provided for all generators, to 
> allow the programmer to deliberately copy RNG state.
>
> Testing, feedback and general usage are all welcome.  I am 
> planning on submitting these to Phobos (although sorting out 
> the generic side of things might be a good idea first).

Nice,

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 !


More information about the Digitalmars-d-announce mailing list