2 ms·
That doesn't resolve the problem for code relying on stable behavior of these functions. Given the following code... srand(CONSTANT); n = rand(); ...the
by gojomo 17y ago
That doesn't resolve the problem for code relying on stable behavior of these functions. Given the following code...
srand(CONSTANT);
n = rand();
...the scenarios I mentioned benefit from n being the exact same number in PHP version X and then version X+1, X+2, etc.
If PHP swaps out both rand() and srand(), backward-compatibility is broken, and along with it some kinds of quite-reasonable code that relied on srand() initializing rand() to give the same deterministic stream of numbers (rather than just a deterministic stream).
It might still be worth taking that hit -- I don't have a strong opinion -- but there are good reasons not to break backwards-compatibility, even to improve PRNG quality.