Hi all, On Wed, Feb 1, 2017 at 5:48 AM, Andrea Faulds <a...@ajf.me> wrote:
> Yasuo Ohgaki wrote: > >> My current objective is to make existing API to work, so resource may be >> used >> to set/get PRNG state. >> > > I would prefer it if we not introduce a new usage of resources. An object > would suffice. > > *** Initialize and Create new PRNG state resource *** >> resource mt_srand([int|string $seed]) >> >> resource: MT rand state resource. >> $seed: I would like to allow large seed like Python and Ruby. >> When seed is string, use all bits for MT rand state >> initialization. >> Example usage: mt_srand(random_bytes(2000)); >> >> *** Get random number from state resource *** >> int mt_rand() // System state >> int mt_rand(resource $state) // Specified user state >> int mt_rand(int $min , int $max [,resource $state]) // Specified user >> state >> if $state is passed >> > > While we could retrofit this into the existing API, it would be cleaner > and friendlier to provide a new one based on objects. Object based implementation is nicer. I agree. I like multi paradigm programming also. We should provide API that users can adopt with minimal cost. IMHO. Therefore, I would like to provide working PRNG for both procedural and object based. I wrote new RFC that fixes issues discussed here. https://wiki.php.net/rfc/improve_predictable_prng_random I used RandomState object so that OO based Random API can use it seamlessly in the future. Comments are appreciated! Regards, -- Yasuo Ohgaki yohg...@ohgaki.net