Hi

For completeness, it would be good to have nextBool() as well.

I'm just wondering if that's really necessary. Generating a boolean is trivial with the nextFloat method (see example 1. Simulate a coinflip from the RFC).

No, IMO. Mathematically it doesn't really make sense and talking about floats, it will also be a very corner case not reached in tests that might happen in production rarely and break things.

Why does it not make mathematical sense? With the nextFloat method, I can understand the argument, because that is otherwise opaque, especially when you work with probabilities. With the getFloat method, however, I can imagine a few cases in which this makes sense. In our example, for example, we calculate a random longitude and latitude with the method. However, the value of Lat: +90.0 Lng: +180.0 cannot be generated, although it is a valid value. However, the value of Lat: -90.0 Lng: -180.0 is included. Am I missing something, or is there currently no simple mathematical way to implement this with an open-right interval?


I am having another small issue.
As the Randomizer class is final, I guess this will not be perfectly polyfillable in userland. So... , if accepted, would it be completely wrong to have these new methods in PHP 8.2? What can it break?

I am relatively new and have little to no experience with contributing PHP functions, but I don't think this should be done. There is a good reason why this is not done and it only causes confusion if any functions are introduced after the feature freeze. In the end, however, I think it is the release manager who decides.


Cheers

Joshua Rüsweg

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: https://www.php.net/unsub.php

Reply via email to