On 01/11/2015 06:05 PM, Stanislav Malyshev wrote: > 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.
Yes, there is plenty of code out there that relies on srand()+rand() returning a repeatable sequence of pseudo-random numbers. I have written some myself. C devs are very familiar with this behaviour of srand. There are tons of uses for this in game-related code. Think of something like Minecraft world seeds. I bet Minecraft even uses this, or at least the Java version of this, for generating its worlds. The worlds are randomly generated, but if you get a particularly cool world you can check the seed and give that seed to a friend and your friend can get the same world generated. There are entire web sites dedicated to sharing cool Minecraft seeds like this. https://www.google.com/search?q=minecraft+seeds -Rasmus
signature.asc
Description: OpenPGP digital signature