On 01/06/2021 16:28, Go Kudo wrote:
Hello internals.
Thanks for continuing to participate in the discussion.
I've sorted out the proposal, and finished writing and implementing the RFC.
(Funny, I know.) I think it's time to start a discussion.
https://wiki.php.net/rfc/rng_extension
https://github.com/php/php-src/pull/7079
The main changes since last time are as follows:
- The ugly RANDOM_USER has been removed.
- RandomNumberGenerator interface has been added for user-defined RNGs.
- Random class is now final.
- Random class now accepts a RandomNumberGenerator interface other than
string as the first argument to the constructor.
- INI directive has been removed. In 32-bit environments, the result is
always truncated.
Overall this looks much better! From a PHP userland perspective I can't
see any huge problem at first glance.
Just a few notes:
- "Random class can be serialized or cloned if the algorithm supports
it." It isn't clear to me how that support is defined in a userland
implementation? Simply by implementing __serialize/__unserialize?
- The __unserialize docblock has two typos (Useri*i*alize and *in*
instead of if)
- If an object is passed to `new Random($obj)`, probably it should throw
an InvalidArgumentException if a seed is also passed in, as I assume in
that case it would be otherwise be ignored.
Best,
Jordi
--
Jordi Boggiano
@seldaek - https://seld.be
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: https://www.php.net/unsub.php