Re: [PHP-DEV] Better name for method Randomizer::nextFloat()

2023-10-16 Thread Tim Düsterhus
Hi On 10/16/23 10:34, Christian Schneider wrote: Am 15.10.2023 um 19:24 schrieb Tim Düsterhus : Making getFloat(float $min = 0.0, float $max = 1.0, IntervalBoundary $boundary = IntervalBoundary::ClosedOpen) would seemingly make it legal to call ->getFloat(0.5), which I consider to be worse th

Re: [PHP-DEV] Better name for method Randomizer::nextFloat()

2023-10-16 Thread G. P. B.
On Mon, 16 Oct 2023 at 09:34, Christian Schneider wrote: > > Side note: The implementation of nextFloat() is much more efficient than > that of getFloat(0.0, 1.0) and the output will differ even for the same > seeded engine. The domain of legal return values is identical. > > This sounds like an

Re: [PHP-DEV] Better name for method Randomizer::nextFloat()

2023-10-16 Thread Christian Schneider
Am 15.10.2023 um 19:24 schrieb Tim Düsterhus : > Making getFloat(float $min = 0.0, float $max = 1.0, IntervalBoundary > $boundary = IntervalBoundary::ClosedOpen) would seemingly make it legal to > call ->getFloat(0.5), which I consider to be worse than nextFloat(). While I understand that you fi

Re: [PHP-DEV] Better name for method Randomizer::nextFloat()

2023-10-15 Thread Tim Düsterhus
Hi On 10/15/23 02:04, tag Knife wrote: I think the major pet peeve i have is that the "Randomizer" class is encapsulating all random functions. I would like to see each randomizer have its own class, since they are under the Random namespace anyway, I believe they should be Random/StringRandomiz

Re: [PHP-DEV] Better name for method Randomizer::nextFloat()

2023-10-15 Thread Tim Düsterhus
Hi On 10/14/23 19:47, David Grudl wrote: random number in the interval 0...1, so it does the same thing as getFloat(0, 1). See https://wiki.php.net/rfc/randomizer_additions#nextfloat For the record: That is correct. B) When trying to think of a more appropriate name (e.g. `getFloat01()` ?),

Re: [PHP-DEV] Better name for method Randomizer::nextFloat()

2023-10-14 Thread tag Knife
On Sat, 14 Oct 2023 at 18:48, David Grudl wrote: > > A) The problem with nextFloat() is that the name creates a false > expectation. Take a look at the following code: > ``` > $randomizer = new \Random\Randomizer(); > $a = $randomizer->getFloat(100, 200); // number between 100..200 > $b = $random

[PHP-DEV] Better name for method Randomizer::nextFloat()

2023-10-14 Thread David Grudl
I would like to suggest changing the name or removing the nextFloat() method, which is coming to PHP 8.3. The Random\Randomizer class will have two new methods for generating random numbers: - getFloat($min, $max [, $boundary]) - nextFloat() Now please try to guess what these methods do and, more

[PHP-DEV] Better name for method Randomizer::nextFloat()

2023-10-14 Thread David Grudl
I would like to suggest changing the name or removing the nextFloat() method, which is coming to PHP 8.3. The Random\Randomizer class will have two new methods for generating random numbers: - getFloat($min, $max [, $boundary]) - nextFloat() Now please try to guess what these methods do and, more