On 12/05/2021 15:39, Go Kudo wrote:
I haven't decided whether to include it in the next RFC, but we think we need to deprecate all functions that use RNGs with global state (shuffle(), array_rand(), str_shuffle()) in the future.
I don't understand why that would be necessary or helpful. The majority of code using those functions does not need repeatable or configurable results, and would not benefit from a more complex API.
If you're just deciding which order to show the user some cute pictures of cats, shuffle($array) is much more appropriate than (new RNG\Randomiser(RNG\MT15593))->shuffle($array) or whatever the API ends up looking like.
I can however see an argument for deprecating srand/mt_srand: if you want a reproducible pseudo-random sequence, create an object to manage its state; if you don't, leave the engine to manage it for you however it wants. The way the seed was initialised would then be entirely an implementation detail, just like the algorithm, which already changed in 7.0.
Regards, -- Rowan Tommins [IMSoP] -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: https://www.php.net/unsub.php