by Scriptor · 17y ago · 0 comments
This is often the case with simulations, or other algorithms that have a 'random' component that you'd still like to hold constant across (for example) related runs during testing or across distributed machines.
So there may be a sensible case for maintaining backward-compatible rand() behavior here, even though a better algorithm is available.
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.