std.random suggestions

GrimMaple grimmaple95 at gmail.com
Mon Sep 22 08:12:23 UTC 2025


On Tuesday, 16 September 2025 at 12:04:20 UTC, Denis Feklushkin 
wrote:
> I don't like the way the module std.random is designed

For one, I really hate how std.random is heavily templated, so it 
ends up being difficult to use in real-world scenarios where you 
might want to hot-swap the random engine for whatever reason. 
With current design choices, you are forced to template your 
stuff too, instead of just writing `IRandom r = new 
WhateverRandom()` and calling it a day.

It was so painful that I ended up doing this 
https://github.com/GrimMaple/mud/blob/master/source/mud/random.d 
, which I use heavily in my games for random level generation.
My current implementation is flawed - it should mark methods as 
`final` so the compiler can figure out to inline the calls when 
needed, but here's that.



More information about the Digitalmars-d mailing list