>> "Why does this method exist at all? When would you use it instead of
>> getInt()?"
>> 
> The case for this would be if you want to get a raw unrounded random number 
> sequence as a number. The situations where this is required would certainly 
> be limited, but it would be nice to have. (At least, I know of several 
> production codes that use the result of mt_rand() with no arguments.)

These two methods confused me at first as well, but I think it's ok with me 
after I check the documentation of mt_rand(), which also supports calling 
without range. So, compatibility is one of the reasons why this method exists, 
although I still feel we should find a better name for them. They are too 
similar now, you won't be able to tell the difference without looking into the 
documentation or source code.

Besides the name issue, I have another question for nextInt(). What's the range 
of its return? It's not clear in the RFC. The range of mt_rand() (without min 
and max) is 0 to mt_getrandmax(), so how about nextInt()? is there any 
equivalent method/constant for it?

Regards,
CHU Zhaowei

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: https://www.php.net/unsub.php

Reply via email to