Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:117898 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 44213 invoked from network); 10 Jun 2022 08:16:01 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 10 Jun 2022 08:16:01 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 5D07F180210 for ; Fri, 10 Jun 2022 03:02:29 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-0.7 required=5.0 tests=BAYES_05,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,HTML_MESSAGE,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS15169 209.85.128.0/17 X-Spam-Virus: No X-Envelope-From: Received: from mail-yb1-f169.google.com (mail-yb1-f169.google.com [209.85.219.169]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Fri, 10 Jun 2022 03:02:28 -0700 (PDT) Received: by mail-yb1-f169.google.com with SMTP id t1so51773ybd.2 for ; Fri, 10 Jun 2022 03:02:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=colopl.co.jp; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=aQsWq75Kzwf48N05gepG16gb+WH5+OoDy5Z8jxFgvP8=; b=Sr1tgC/WeTZhnB1X5hzcDOcFKJ6BfDfkbQreCWsXG8xCh+kTN8ShkMOgmKC2CfJ3vm Wjxgc5PPbVu8aLGklA2ZeIUPdSO2P/du0erhAwtgi6/36McB28USF861Heak3ULLf7Au g8OVkCSqwA0dXfi7VvAXXPXgEJlZ+JYoj7zW7DMQbPZfuepldUvPxKGeR9+CFo3jQbfp Ax0MTxxTd7f5mMP1m77vIEx5k8Yo/1Jlgn/j3mCCHrPOk90WNa1BeFJuT2ivjyTJxtpp iDd9tJmjHrAer04BEZDvL3MI/vSsi4SrPHkJCFUiNEUvElUR4zLk+kLIejomh1O4kv3g 8SwQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=aQsWq75Kzwf48N05gepG16gb+WH5+OoDy5Z8jxFgvP8=; b=7qsBaeVDh0fRocdOm0CpuJS4/0X43xCuLeXGqfFUtem4rTxXUX6o7gBXfseqI3MWtB TPSu0wIDypWoFLM6utt3ATb/Pqh/58jgNj3CaGnHPL3MO4nWrLVK2Ygxu5tXpnQYLI88 6BCiycpFoI0qRcYhu6a7j1po7qqOd79wISEc+Q1XocyoIWivyDOZqrPSCW1acmnnLbfv X5deA2JzTSB8jt4vh+D/NIcrnuAhRrH2UVOFE1vn9rZv4LvvEGoURDmwHqPY8PSVtx4L g5XaESFsOwzjouSsheJLUaaDCxl3MadrzuAJAMHZOF/S0jc1o0Q9BXsjdj57gRwOEq/k DepQ== X-Gm-Message-State: AOAM53050VU6lEUO5/ry5RvcgkiVb5lEtYws8sUWtaKXTcp0qBW68tdk FxhlMPrpz+HaCW1z2kuWaI/PCXqiGwBXxih7kM1iWwkKGOhCWCY= X-Google-Smtp-Source: ABdhPJw/7lya3TCm8iET0TKi4+tofILAhOXUI7Hv0fpmxefg3QHzKSCSkIhqM/a1mwAwTOkFE/tpy4iv8gqsI08lTK4= X-Received: by 2002:a25:77d8:0:b0:663:5e85:a632 with SMTP id s207-20020a2577d8000000b006635e85a632mr29447729ybc.375.1654855348219; Fri, 10 Jun 2022 03:02:28 -0700 (PDT) MIME-Version: 1.0 References: <77a67ec1-2b32-0e86-3714-9b2600691c18@bastelstu.be> In-Reply-To: <77a67ec1-2b32-0e86-3714-9b2600691c18@bastelstu.be> Date: Fri, 10 Jun 2022 19:02:17 +0900 Message-ID: To: =?UTF-8?Q?Tim_D=C3=BCsterhus?= , internals@lists.php.net Content-Type: multipart/alternative; boundary="0000000000002f86c105e11509f9" Subject: Re: [PHP-DEV] [RFC] [Vote] Pre-vote announcement for Random Extension 5.x From: g-kudo@colopl.co.jp (Go Kudo) --0000000000002f86c105e11509f9 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 2022=E5=B9=B46=E6=9C=888=E6=97=A5(=E6=B0=B4) 0:24 Tim D=C3=BCsterhus : > Hi > > On 5/31/22 11:54, Go Kudo wrote: > > - More detailed description in RFC > > > > a) > > For the Random\Engine interface I suggest to clarify that the returned > bytestring will be interpreted as a little endian integer. > > b) > > I'm still missing an explanation of the guarantees the Randomizer > implementation will make (last bullet point in > https://externals.io/message/117295#117299). > > To me the guarantees is the most important thing about this RFC. As a > user of the API I need to know what of the behavior can and what cannot > change in future PHP versions. I don't really care whether the RNG is > PCG64 or some Xoshiro. Both are great. > > The Engine part is pretty solid: They implement a well-defined RNG and > any numbers are returned as little endian integers (see (a)). Either the > implementation is correct or it is not. This is not likely to change in > the future. > > However the Randomizer part is pretty undefined: As an example: > ->getInt() will return an integer uniformly selected from the given > range. But there's more than one way to perform this uniform selection. > Will the algorithm stay the safe in future PHP versions? There are more > examples in my previous emails. > > Best regards > Tim D=C3=BCsterhus > Hi Tim. Thanks for the continued feedback! I have added the following regarding the points you pointed out. * interface Random\Engine > It has a single generate(): string method that generates random numbers as a binary string. This string must be non-empty and attempting to return an empty will result in a RuntimeException. > If you implement a random number generator in PHP, the generated numbers must be converted to binary using the pack() function, and the values must be little-endian. * class Random Randomizer > The same current PHP algorithm is used to generate random numbers within the specified range in Randomizer::getInt(). This is necessary for backward compatibility. > It also provides a guarantee of consistency in the future. However, I understand that perhaps this fix will not satisfy your request. I just do not have a good understanding of your intentions due to my poor English.... I am considering the following possibilities regarding your intentions: 1. Should be stated in detail so that consistency of results is maintained in the future. 2. Current PHP ranged random number generation algorithm has room for improvement and should be examined further 3. Consistency of results is difficult to maintain in the future (Maybe incorrect) In case 1, I think the following statement would satisfy the requirement. > The values generated by the seedable Engine guarantee future reproducibility of results, and the Randomizer uses the results to process them, so if the results generated by the Engine are identical, the Randomizer's results will also be consistent. Although the consistency of the Randomizer results is not mentioned here, it would be a clear BC Break if the results were to change after the Randomizer is officially implemented, so I do think it is sufficient that an RFC be created and voted on as necessary. In case 2, I also thought about it along the way. Nikita also taught me about better algorithms: https://externals.io/message/115918#115982 But, I also think that the current PHP implementation is good enough, and there is no need to change it to the point of breaking compatibility. I think the current global scope MT implementation is very troublesome for some use cases and should first be able to be drop-in-replaceable with this implementation. In case 3, I think it is necessary to guarantee consistency at least once at the language level, even though this may change in the future. I have already indicated the need for this in the RFC. Most of all, I do not believe you intend this to be the case. (And this sentence is not intended to offend you either. Please don't misunderstand me.) I would like to hear more about your opinion. Regards, Go Kudo --0000000000002f86c105e11509f9--