Re: Confusion about `Random`

2022-12-24 Thread Salih Dincer via Digitalmars-d-learn
On Saturday, 24 December 2022 at 17:58:04 UTC, jwatson-CO-edu wrote: Ali, your post contained at least 3 things I did not previously know about D; thank you! And thank you all for helping troubleshoot this issue with my hobby language! Thank you for completing me: Tesekkurler hocam in Turkis

Re: Confusion about `Random`

2022-12-24 Thread Ali Çehreli via Digitalmars-d-learn
On 12/24/22 09:58, jwatson-CO-edu wrote: >> ~static this() Should be 'static ~this()'. >> ~shared static this() Should be 'shared static ~this()'. > thank you all Happy to be helpful... Ali

Re: Confusion about `Random`

2022-12-24 Thread jwatson-CO-edu via Digitalmars-d-learn
On Saturday, 24 December 2022 at 16:34:29 UTC, Ali Çehreli wrote: static this() blocks: executed when a thread a starts (the program has at least one thread: the main thread); so you can put initializations here ~static this() blocks: counterparts of 'static this', executed once for each thre

Re: Confusion about `Random`

2022-12-24 Thread jwatson-CO-edu via Digitalmars-d-learn
On Saturday, 24 December 2022 at 16:42:36 UTC, Siarhei Siamashka wrote: Sounds like a case of https://xkcd.com/221/ BTW, you don't need to explicitly initialize unpredictableSeed, Another thing is that the current implementation of `std.random` in Phobos is extremely slow Even better, I aut

Re: Confusion about `Random`

2022-12-24 Thread Siarhei Siamashka via Digitalmars-d-learn
On Saturday, 24 December 2022 at 16:16:17 UTC, jwatson-CO-edu wrote: Then it became clear that the parser was replacing calls to `rand` with a number, which was displayed repeatedly when a loop was evaluated. Sounds like a case of https://xkcd.com/221/ BTW, you don't need to explicitly initia

Re: Confusion about `Random`

2022-12-24 Thread Ali Çehreli via Digitalmars-d-learn
On 12/24/22 08:18, jwatson-CO-edu wrote: > On Friday, 23 December 2022 at 07:25:23 UTC, Salih Dincer wrote: >> You can try using static this. >> >> ```d >> import std.random; >> >> static this() { } // can try using static this() blocks: executed when a thread a starts (the program has at least

Re: Confusion about `Random`

2022-12-24 Thread jwatson-CO-edu via Digitalmars-d-learn
On Friday, 23 December 2022 at 17:53:24 UTC, H. S. Teoh wrote: 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 mi

Re: Confusion about `Random`

2022-12-24 Thread jwatson-CO-edu via Digitalmars-d-learn
On Friday, 23 December 2022 at 07:25:23 UTC, Salih Dincer wrote: You can try using static this. ```d import std.random; static this() { } // can try using Mt19937 rnd; void init_random() { rnd = Random(unpredictableSeed); } double rand01() { return uniform(0, 1.0, rnd); } void main() {