Hi

On 6/20/22 16:57, Nicolas Grekas wrote:
I'm wondering: does Random\SerializableEngine extend Random\Engine? Can
this be mentioned in the RFC? If not, what about making it this way? Having
this interface only contain __(un)serialize would look strange to me, aka
too broad for the name and the purpose.

Yes, it does. All the other interfaces extend Random\Engine as well. See the stub at:

https://github.com/colopl/php-src/blob/upstream_rfc/scoped_rng_for_pr/ext/random/random.stub.php

I'm also wondering: is CombinedLCG worth it? I must admit I don't know when
I should use it instead of MT19937.

If the RFC passes you really should use neither:

- CombinedLCG: That's a horrible RNG, that is implemented for backwards compatibility with the existing functionality. - MT19937: That one is not quite as horrible, but it comes with 2.5kB of state. It's also implemented for backwards compatibility with the existing RNGs (it's what backs rand() and mt_rand()).

Use 'Secure', you can't do anything wrong with that and that's why it's the default for the Randomizer.

If you need performance or if you need support for seeding then either use PCGOneseq128XslRr64 or Xoshiro256StarStar (depending on whether the latter makes it into the extension).

Since the names are all super opaque to many of us, documentation should be
very clear about the use case of each implementation... (if can reduce the
number of implementations, that's even better :) )

Regarding the names: Yes, they are opaque, but will become a little less opaque if the extension RFC passes, because then the names will refer to a very specific implementation of standard RNGs, making them Googleable.

For Xoshiro256StarStar the upstream documentation is here:

https://prng.di.unimi.it/

For PCGOneseq128XslRr64 the upstream documentation is here:

https://www.pcg-random.org/

But I agree that the documentation should help the user make an educated choice.

Best regards
Tim Düsterhus

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

Reply via email to