Confusion about `Random`

H. S. Teoh hsteoh at qfbox.info
Fri Dec 23 17:53:24 UTC 2022


On Fri, Dec 23, 2022 at 03:21:24PM +0000, jwatson-CO-edu via Digitalmars-d-learn wrote:
> On Friday, 23 December 2022 at 00:00:06 UTC, H. S. Teoh wrote:
[...]
> > 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.
[...]
> 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?

Hmm, in that case it's probably not a problem with `ref`.

You probably should give DustMite a shot; from the snippets you've
posted so far we haven't found any clues of what might have gone wrong.
To narrow down the issue we really need to start from the original code
and reduce it to a minimal case.

	https://github.com/CyberShadow/DustMite


T

-- 
Дерево держится корнями, а человек - друзьями.


More information about the Digitalmars-d-learn mailing list