Re: [RFC] RNG fixes
| From: | Fleshgrinder | Date: | Thu, 23 Jun 2016 20:37:21 +0000 |
| Subject: | Re: [RFC] RNG fixes | ||
| References: | 1 2 3 4 5 6 7 8 9 10 11 12 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-94239@lists.php.net to get a copy of this message | ||
On 6/23/2016 6:56 PM, Stanislav Malyshev wrote:
> Hi!
>
>> I would prefer something like random_fast_int() == mt_rand() == rand(),
>> with clear documentation on when to use random_fast_int() instead of
>> random_int(), and a note on the others that "since 7.2, mt_rand() is an
>> alias for random_fast_int()" etc. (Not wedded to the name
>> random_fast_int, we can bikeshed that later.)
>
> That sounds to me like a good way to proceed too. I don't think it's a
> big deal it mt_rand won't be using specific MT algorithm anymore, I see
> very small number of places where it would matter.
>
> One thing to consider is that there might be test scenarios, sequences,
> etc. that depend on specific seed and will be broken by changing the
> implementation (tests relying on specific rand are not the very best
> idea, but they do happen), but I think this kind of thing may be
> acceptable for a major version. Would like to hear thoughts on this though.
>
+1 for the introduction of a new function that is named similar to
random_int() but clearly distinguishable followed by aliasing in PHP 8
of mt_rand() and rand().
The agenda would be:
1. Decide on a signature for that new function.
2. Decide on a name for that new function.
3. Decide on an algorithm for that new function.
4. Implement it.
5. Update the documentation or rand() and mt_rand() to mention the plans
for aliasing.
6. Alias them in PHP 8.
Nice to see that we come to something that satisfies everyone. :)
--
Richard "Fleshgrinder" Fussenegger
Attachment: [application/pgp-signature] OpenPGP digital signature signature.asc
Attachment: [application/pgp-signature] OpenPGP digital signature signature.asc