Ranges and random numbers -- again

Jonathan M Davis jmdavisProg at gmx.com
Tue Jun 18 12:35:31 PDT 2013


On Tuesday, June 18, 2013 15:21:23 Andrei Alexandrescu wrote:
> How about defining rndGenRef and putting rndGen on the deprecation path?

We could, though that's a bit ugly as names go IMHO. We could almost get away 
with simply changing what rndGen returns, but unfortunately, it returns Random 
rather than auto, so if anyone typed it explicitly, we'd break their code - 
unless we changed Random to be aliased to Class!Mt19937 instead of Mt19937, 
but then anything using Random explictly without rndGen would break. My 
_guess_ would be that we could get away with just changing rndGen to return 
something else and break almost no one, but unfortunately we can't know that 
for sure. We probably should have had rndGen return auto rather than Random, 
but we have more experience with ranges now than when std.random was written.

Regardless, I think that we should be sure of what we want to do with the 
module as a whole before we start making tweaks like that, since if we decide 
that we really do want std.random2, there's not much point in tweaking 
std.random, and std.random2.rndGen could return what we want. If we do stick 
with std.random though, I think that we should come up with a better name than 
rndGenRef (maybe rndRange or genRnd or simply random).

- Jonathan M Davis


More information about the Digitalmars-d mailing list