Re: rand(), mt_rand() and limits
| From: | Stanislav Malyshev | Date: | Mon, 12 Jan 2015 02:05:30 +0000 |
| Subject: | Re: rand(), mt_rand() and limits | ||
| References: | 1 2 3 4 5 6 7 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-80404@lists.php.net to get a copy of this message | ||
Hi!
> Also, FWIW, anyone who used the Suhosin patch couldn’t use srand()
> because it disabled it.
And? You can disable any function in PHP, that doesn't mean anything.
> Because if we don’t break it, people will continue to rely on it, and
> this binds our hands for future versions.
Sorry, that doesn't sound even remotely like a good reason. It doesn't
provide any benefit to the user, but produces problems for those who use
it. The gain for the users is zero, the added trouble - for those who
use the feature - is substantial.
> Also, those people will have their code break anyway if they upgrade
> their OS and it changes its random number generator.
If they used mt_rand that is not true. And OS RNG changes are not that
frequent. E.g. the manual for srand on Mac (and, likely, all BSD) says:
The srand() function sets its argument seed as the seed for a new
sequence of pseudo-random numbers to be returned by rand().
These sequences are repeatable by calling srand() with the same seed value.
The Linux manual says:
The srand() function sets its argument as the seed for a new
sequence of pseudo-random integers to be returned by rand().
These sequences are repeatable by calling srand() with the same seed value.
I would say the expectation here is pretty clear.
> Just because people do rely on it doesn’t mean they should or that we
> should continue to allow them to.
It doesn't mean they should, but it does mean it is a BC break, and one
that produces no discernible gain at that.
--
Stas Malyshev
smalyshev@gmail.com