Re: [PHP-DEV] Re: Improving PRNG implementation.

2021-01-06 Thread Go Kudo
Hello Nikita. > In addition to the functions you already list, I'd add >function rng_bytes(RNGInterface $rng, int $length): string; >function rng_between(RNGInterface $rng, int $min, int $max): int; Certainly these are useful. I've added this to the RFC in TypeC. > Just to share another

Re: [PHP-DEV] Re: Improving PRNG implementation.

2021-01-06 Thread Nikita Popov
On Tue, Jan 5, 2021 at 6:40 PM Go Kudo wrote: > Thanks Nikita. > > Thanks for the input. This looks like a very smart solution. > I've edited the RFC and added a new proposal as TypeC. > > https://wiki.php.net/rfc/object_scope_prng > In addition to the functions you already list, I'd add

Re: [PHP-DEV] Re: Improving PRNG implementation.

2021-01-05 Thread Go Kudo
Thanks Nikita. Thanks for the input. This looks like a very smart solution. I've edited the RFC and added a new proposal as TypeC. https://wiki.php.net/rfc/object_scope_prng However, I have a couple of concerns. The first is that users will have to be careful with RNG instances (for better or

Re: [PHP-DEV] Re: Improving PRNG implementation.

2021-01-05 Thread Nikita Popov
On Thu, Dec 24, 2020 at 5:12 PM zeriyoshi wrote: > I updated the RFC draft and changed it to a proposal to bifurcate the > interface. > > https://wiki.php.net/rfc/object_scope_prng > > At the same time, I was looking into the RNG problem in Swoole and found > out that the problem was actually

Re: [PHP-DEV] Re: Improving PRNG implementation.

2021-01-03 Thread Marc
On 01.01.21 20:22, Go Kudo wrote: > Hi Marc, and sorry for the late reply. Email has been marked as spam... > >> I would expect the Random number generator to implement from Iterator > using an integer for current() value >> and providing utility functions (simple functions or methods of another

[PHP-DEV] Re: Improving PRNG implementation.

2021-01-02 Thread Go Kudo
Unfortunately, there is not much feedback on this proposal. To remedy the situation, we have updated the RFC and implemented it. https://wiki.php.net/rfc/object_scope_prng https://github.com/php/php-src/pull/6568 Currently, it seems to work generally as expected, although it has failed to be

Re: [PHP-DEV] Re: Improving PRNG implementation.

2021-01-01 Thread Go Kudo
Hi Marc, and sorry for the late reply. Email has been marked as spam... > I would expect the Random number generator to implement from Iterator using an integer for current() value > and providing utility functions (simple functions or methods of another class) for shuffle, random array entry

Re: [PHP-DEV] Re: Improving PRNG implementation.

2020-12-29 Thread Marc
Hi zeriyoshi, On 23.12.20 14:41, zeriyoshi wrote: > Thanks tyson. > >> This would also make it easier to use those generators in brand new > algorithms that weren't in the initial RFC. >> (or in algorithms written by users in PHP) > This suggestion seems to make sense. Maybe the RNG should only

[PHP-DEV] Re: Improving PRNG implementation.

2020-12-24 Thread zeriyoshi
I updated the RFC draft and changed it to a proposal to bifurcate the interface. https://wiki.php.net/rfc/object_scope_prng At the same time, I was looking into the RNG problem in Swoole and found out that the problem was actually occurring. https://www.easyswoole.com/En/Other/random.html The

Re: [PHP-DEV] Re: Improving PRNG implementation.

2020-12-23 Thread zeriyoshi
Thanks tyson. > This would also make it easier to use those generators in brand new algorithms that weren't in the initial RFC. > (or in algorithms written by users in PHP) This suggestion seems to make sense. Maybe the RNG should only focus on generating random numbers and not anything else.

Re: [PHP-DEV] Re: Improving PRNG implementation.

2020-12-22 Thread tyson andre
HiĀ Go Kudo, **A possible alternative that is widely used in other programming languages is to limit the interface API to only generating bytes/integers,** and to provide global functions that would use generic random number generator objects (from internal or user-provided code) in their

Re: [PHP-DEV] Re: Improving PRNG implementation.

2020-12-22 Thread zeriyoshi
Thanks. I have edited the RFC based on your question. > Method names: you don't need to emulate the conventions from non-OOP code, e.g. string_shuffle() --> strShuffle and array_rand() --> arrayRand(). Use a more naturally readable convention like shuffleString(). As mentioned in the RFC, it is

Re: [PHP-DEV] Re: Improving PRNG implementation.

2020-12-20 Thread Max Semenik
On Sun, Dec 20, 2020 at 6:45 AM zeriyoshi wrote: > Thanks cmb. I have created a first draft of an RFC. I think I've covered > all the necessary requirements, but I'd like to know if there are any > problems. > https://wiki.php.net/rfc/object_scope_prng A few IMHO comments: * Namespaces are

[PHP-DEV] Re: Improving PRNG implementation.

2020-12-20 Thread Christoph M. Becker
On 20.12.2020 at 04:45, zeriyoshi wrote: > On 19.12.2020 at 11:26, Christoph M. Becker wrote: > >> RFC karma granted. Best of luck with the RFC! :) > > Thanks cmb. I have created a first draft of an RFC. I think I've covered > all the necessary requirements, but I'd like to know if there are any

[PHP-DEV] Re: Improving PRNG implementation.

2020-12-19 Thread zeriyoshi
On 19.12.2020 at 11:26, Christoph M. Becker wrote: > RFC karma granted. Best of luck with the RFC! :) Thanks cmb. I have created a first draft of an RFC. I think I've covered all the necessary requirements, but I'd like to know if there are any problems.

[PHP-DEV] Re: Improving PRNG implementation.

2020-12-19 Thread Christoph M. Becker
On 19.12.2020 at 07:33, zeriyoshi wrote: > On Wed, Dec 16, 2020 at 8:46 AM zeriyoshi wrote: > > I have created an account on the PHP.net wiki to create an RFC about this. > Can you grant me editing privileges? RFC karma granted. Best of luck with the RFC! :) Christoph -- PHP Internals - PHP

[PHP-DEV] Re: Improving PRNG implementation.

2020-12-18 Thread zeriyoshi
On Wed, Dec 16, 2020 at 8:46 AM zeriyoshi wrote: Hello. I have created an account on the PHP.net wiki to create an RFC about this. Can you grant me editing privileges? As for suggestion two, I sent a PR to php-src on GitHub. https://github.com/php/php-src/pull/6520 Fortunately, Nikita seems