Re: Re: [RFC] [VOTE] Random Extension 5.x

From: Date: Fri, 17 Jun 2022 17:46:24 +0000
Subject: Re: Re: [RFC] [VOTE] Random Extension 5.x
References: 1 2 3 4 5  Groups: php.internals 
Request: Send a blank email to internals+get-117990@lists.php.net to get a copy of this message
2022年6月18日(土) 2:37 Tim Düsterhus <tim@bastelstu.be>: > Hi > > On 6/17/22 19:28, Go Kudo wrote > >> I don't think that ->pickString() is a good name > > > > I see. But I think randomString() is ambiguous with > > getBytes(). > > > > stringFromCharset(string $string, int $num): string solves > > that, but I > > think it is possible > > that the meaning of "char" is not well known in the PHP world (although I > > think this name is most appropriate) > > ->stringFromAlphabet()? > > > How about adding an optional ?int $num argument to > `shuffleString(string > > $string, ?int $num): string`? > > > > No, because it would be pretty unclear what that $num argument > would > do there. It specifically would be different from the $num of > pickArrayKey(). pickArrayKey() returns every key only once. > Generating > a string from a given charset may return the same character multiple > times. Don't overload a single method with too many purposes. > > Best regards > Tim Düsterhus > I was fundamentally wrong, I understand now. As you said, there was no interoperability with pickArrayKey() in the first place... > stringFromAlphabet() Hmmm. I guess randomString would be better then. At the same time, it would be nice to have an array version of randomArray. However, I don't want to add more methods without any thought. I think operations that can be done on userland should be done on userland. That is why I did not implement the array_rand() function in the first place. I would like to hear other people's opinions in this area. Incidentally, our own PHP implementation of the library (Xorshift128+) has equivalents for arrayPickKey, stringPick, arrayPickValue, randomArray, randomString. And it is useful. Regards Go Kudo

« previous php.internals (#117990) next »