2022年10月14日(金) 13:33 Alexandru Pătrănescu <dreal...@gmail.com>:

> On Thu, Oct 13, 2022, 22:37 Joshua Rüsweg via internals <
> internals@lists.php.net> wrote:
>
> > Hi
> >
> > Tim Düsterhus and I have created an RFC to add new methods that solve
> > commonly encountered use cases to \Random\Randomizer. Specifically
> > creating a random string consisting of specific bytes and generating
> > random floating point values.
> >
> > You can find the RFC at:
> >
> > https://wiki.php.net/rfc/randomizer_additions
> >
> > Proof of concept implementation is in:
> >
> > * https://github.com/php/php-src/pull/9664
> > * https://github.com/php/php-src/pull/9679
> >
> >
> >
> > Some open questions to start the discussion:
> >
> > * Are you missing other commonly useful operations that are also useful
> > to have in core?
> >
>
> For completeness, it would be good to have nextBool() as well.
>
> * Do you agree with the method names? Within the PR we received comments
> > that "alphabet" might not be an appropriate term.
> >
>
> Yes, alphabet is fine by me but I can suggest also: character set,
> character list, character dictionary, byte set, byte list, byte dictionary
> or some shortcuts of it, like charset.
>
> * Shall an option be added to getFloat() that changes the logic to
> > select from [$min, $max] (i.e. allowing the maximum to be returned)? And
> > how should that look like? Boolean parameter? Enum?
> >
>
> 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.
>
>
> > ----
> >
> > We're looking forward to your feedback.
> >
> >
> > Cheers
> >
> > Joshua Rüsweg
> >
> > --
> > PHP Internals - PHP Runtime Development Mailing List
> > To unsubscribe, visit: https://www.php.net/unsub.php
> >
>
> >
> >
> 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?
>

> As the Randomizer class is final, I guess this will not be perfectly
polyfillable in userland.

What case do you envision for this? Probably, most cases can be polyfilled
by code: https://3v4l.org/JludD

And it seems that someone has already done such an implementation (which is
very nice and I would like to express my utmost appreciation).

https://github.com/arokettu/php-random-polyfill

Regards
Go Kudo

Reply via email to