Confusion about `Random`

jwatson-CO-edu real.name at colorado.edu
Fri Dec 23 15:21:24 UTC 2022


On Friday, 23 December 2022 at 00:00:06 UTC, H. S. Teoh wrote:
> You could try using DustMite to reduce it to a minimal (or at 
> least
> smaller) example.
>
> My personal guess is that you forgot a `ref` somewhere when you 
> pass the RNG to a function.  Given that due to historical 
> accident std.random uses structs for RNG implementations, and 
> this can sometimes lead to unexpected results when you 
> unintentionally passed an RNG state by value instead of by 
> reference.  One thing to try could be to scan all your function 
> signatures where an RNG is passed, and make sure there's a 
> `ref` on it.
> T

I had not passed the RNG in any case, but instead accessed the 
global RNG from inside any function that uses it.  Is that a 
potential issue?




More information about the Digitalmars-d-learn mailing list