Andrei Alexandrescu, el 13 de febrero a las 17:10 me escribiste:
> Leonardo suggested that some functions in std.random should not require their 
> user to be bothered with creating a random object, i.e.:
> 
> auto r = Random(unpredictableSeed);
> auto n = uniform(r, 0, 100);
> 
> Instead the library should simply support:
> 
> auto n = uniform(0, 100);
> 
> and do this by presumably using a global RNG under the hood. So I wanted to 
> ask 
> all y'all:
> 
> 1. Are you cool with making the rng the last parameter and give it a default 
> value?

Yes

> 2. The global random generator will be allocated per thread. Are you cool 
> with 
> this too?

Yes

> 3. How should the global rng be initialized? To always generate the same 
> sequence, or not?

NO! I think this feature is for small script-like programs, where the most
common case is you want a random number to be random =)

If you want to do some more complicated stuff, just set the seed yourself.

> 4. While we're at it, should uniform(a, b) generate by default something in 
> [a, 
> b] or [a, b)? Someone once explained to me that generating [a, b] for 
> floating 
> point numbers is the source of all evils and that Hitler, Stalin and Kim Il 
> Sung 
> (should he still be alive) must be using that kind of generator. Conversely, 
> generating [a, b) is guaranteed to bring in the long term everlasting peace 
> to 
> Earth. My problem however is that in the integer realm I always want to 
> generate 
> [a, b]. Furthermore, I wouldn't be happy if the shape of the interval was 
> different for integers and floating point numbers. How to break this 
> conundrum? 
> Don't forget that we're only worrying about defaults, explicit generation is 
> always possible with self-explanatory code:

Being a C and Python programmer mostly, I find more intuitive [a, b) (The
'for' statement is usually used that way, same for the Python's range()
function)

-- 
Leandro Lucarella (luca) | Blog colectivo: http://www.mazziblog.com.ar/blog/
----------------------------------------------------------------------------
GPG Key: 5F5A8D05 (F8CD F9A7 BF00 5431 4145  104C 949E BFB6 5F5A 8D05)
----------------------------------------------------------------------------
Un paracaidista, que no deja de caer.
Lo que me lleva hacia arriba, es lo que me tira hacia abajo.

Reply via email to