Re: [VOTE] Object scoped RNG implementation
Hi Xavier
> If I understand correctly, this would
> - provide us with performant object-encapsulated (isolated from global
state) equivalents of the existing mt_srand()/mt_rand() and
random_int() functions as well as a new "XorShift128+"; along with some
global functions for usability, notably rng_bytes() and rng_int()
respectively similar to random_bytes() and random_int() but with an
additional (first) RNG argument
> - enable us to use them (the objects), as well as other (extension or
userland) implementations of the RNG\RNGInterface, for the existing
array_rand(), shuffle() and str_shuffle() functions (instead
of the
default internal MT implementation)
Yes, that's right.
> I can't vote (yes), but I just suggest you complete the stubs in the RFC
with what can been seen at <
https://github.com/php/php-src/pull/6568/files?file-filters%5B%5D=.php#diff-d469bf38690924187e7b9db4a8ab199a99394b404bb12325a789141c56edb12f>
and below, showing that the class OS has the minimal interface while
classes MT19937 and XorShift128Plus have a public
__construct(int $seed) and implement the magic
__serialize()/__unserialize().
I've added it to the RFC.
Thank you!
Thread (12 messages)