Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:115976 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 29887 invoked from network); 6 Sep 2021 19:56:10 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 6 Sep 2021 19:56:10 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 5A376180538 for ; Mon, 6 Sep 2021 13:33:27 -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=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,HTML_MESSAGE, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS 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-ed1-f42.google.com (mail-ed1-f42.google.com [209.85.208.42]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Mon, 6 Sep 2021 13:33:26 -0700 (PDT) Received: by mail-ed1-f42.google.com with SMTP id q3so10882526edt.5 for ; Mon, 06 Sep 2021 13:33:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=Dx/B8Q5X4e3lU/+83sQmg1VBTRsgRHOzQTphy7KCK7c=; b=dM/16T+yOVwuJBtpkuUXdh2l65SCV5ufkIktpwnvs3bj5qKT2VqdBbcZfXCEGHqrjo FgT01GLAtLXVhjpF2UmgIn3UezyIKL/Pj+LweeY7RkibPeZhiiIPifNs04IWYsm5Hgon TFchdyYJDZf8mH1Rvd6w6SgkvDiP8EDvqqZ7WtikzOebHXknEsukGQcnfUTqtaOSx5tR 0Q0IE+Q2vq3yiKnNjc1K2iKHEbMNrND8R1tGyNoMUo8q//MeeRjOLH/GRbzqVyhUpVnC VG3DDQRoR9un1U0S07iyhm5nGpKOGQ5tGdsfG+LGaQCv/EZAw9FHK1xJjkaQqSmBp5FG L25g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=Dx/B8Q5X4e3lU/+83sQmg1VBTRsgRHOzQTphy7KCK7c=; b=diK2XBITtgB5+A5EdvB1s4ZNViXmYdxo6AhXxCx/kvQCzVWJx0T4MZ5HIgYg9mqTlk Xh1aMMWME+yjJ0ROLTZNdxlE1cvKNt66s46WaCf4Q+ff/K0w0EIa1fQuz1uSKd3MQ3TK aHYXTII6yBr/Q0wHoz+e9vsROouBefhVRpNlJwEhRAnWOk1dZSrU3XbSHiu6Wm7KbeHQ oo+GlXgSlMMwmMIGPCdt9k9M209KLtPwv9blGlp3MP4/tCtC1h1QgKIWHyMZsW1g4G2a 572OqH9xe0JtTS4R0bmC/UTNtWIgt/ef9hTjaLQmfYxCbcLH/HybLc/Zk3X47T3prgrF NG/A== X-Gm-Message-State: AOAM533AH55B/UBvKQtk6NLnwITu/wGxQQ52Ke74xk6R20gwujfnoWjc yfJl+Eiw6r7Axy1RwtyLyceSh8Pxrrd+0CszBtMiXpDAuDk= X-Google-Smtp-Source: ABdhPJxOi5tU/JQZAzhYITI8HCSM06blqU9qeiRoFLPkuTVrUJzaXqUbgXi4cJ7yyzYcU37CbImA3ablrtReQgrkXJk= X-Received: by 2002:aa7:cd92:: with SMTP id x18mr14797965edv.325.1630960405453; Mon, 06 Sep 2021 13:33:25 -0700 (PDT) MIME-Version: 1.0 References: <61339ad1.1c69fb81.b518e.8644SMTPIN_ADDED_MISSING@mx.google.com> <61350112.1c69fb81.82294.dff2SMTPIN_ADDED_MISSING@mx.google.com> <61364ec1.1c69fb81.3ef56.96dcSMTPIN_ADDED_MISSING@mx.google.com> In-Reply-To: <61364ec1.1c69fb81.3ef56.96dcSMTPIN_ADDED_MISSING@mx.google.com> Date: Tue, 7 Sep 2021 05:33:14 +0900 Message-ID: To: Ben Ramsey , Nikita Popov , PHP internals Content-Type: multipart/alternative; boundary="0000000000009c1ff105cb598f16" Subject: Re: [PHP-DEV] Re: [RFC] Random Extension 3.0 From: zeriyoshi@gmail.com (Go Kudo) --0000000000009c1ff105cb598f16 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Nikita, Thanks for the clarification. That's exactly what I intended to do. > can you update the RFC with more information about this functionality? I understand. Organize them and reconstruct the RFC text. I've also created an RFC about moving RNG-related functions from ext/standard to ext/random. I would appreciate it if you could check it out= . https://wiki.php.net/rfc/random_ext Regards, Go Kudo 2021=E5=B9=B49=E6=9C=887=E6=97=A5(=E7=81=AB) 2:24 Ben Ramsey : > Nikita Popov wrote on 9/6/21 03:06: > > On Sun, Sep 5, 2021 at 7:40 PM Ben Ramsey wrote: > > > >> Go Kudo wrote on 9/4/21 23:00: > >>> Indeed, it may be true that these suggestions should not be made all = at > >>> once. If necessary, I would like to propose to organize the RNG > >>> implementation first. > >>> > >>> Do we still need an RFC in this case? I'm not sure I'm not fully > >> understand > >>> the criteria for an RFC. Does this internal API change count as a BC > >> Break > >>> that requires an RFC? > >> > >> Yes, since re-organizing the RNG implementation is a major language > >> change that affects extensions and other downstream projects, this > >> requires an RFC. > >> > >>>> Personally, I don't see the benefit of including this OOP API in the > >> core. > >>> > >>> On the other hand, can you tell me why you thought it was unnecessary= ? > >>> Was my example unrealistic? > >> > >> You also said, in reply to Dan Ackroyd: > >> > >>> Either way, I'll try to separate these suggestions if necessary, but = if > >> we > >>> were to try to provide an OOP API without BC Break, what do you think > >> would > >>> be the ideal form? > >> > >> The OOP API appears to be a wrapper around the RNG functions. The only > >> thing it gains by being in the core is widespread use, but it loses a > >> lot of flexibility and maintainability, since the API will be tied to > >> PHP release cycles. > >> > >> By doing this as an OOP wrapper in userland code, you're not restricti= ng > >> yourself to release only when PHP releases, and you can work with the > >> community (e.g., the PHP-FIG) to develop interfaces that other project= s > >> might use so they can make use of their own RNGs, etc. > >> > > > > The OO API is not just a wrapper around the RNG functions -- it provide= s > > new functionality that cannot be efficiently implemented in userland > code. > > This is for two reasons: > > > > 1. It provides independent randomness streams, which means it's not > > possible to reuse existing functionality like mt_rand() for this purpos= e, > > which only provides a single global random number stream. You would hav= e > to > > reimplement the random number generator in userland. While this is > > possible, it will generally not be efficient, because PHP does not have > > native support for unsigned modular arithmetic, which is what random > number > > generators generally need. > > > > 2. It allows using functions like shuffle() and array_rand() with an > > independent randomness stream. These functions cannot be efficiently > > implemented in userland, because userland does not have random access t= o > > arrays. Internals can generate a random number and use it to pick the k= ey > > at that position, which is O(1). Userland would have to call array_keys= () > > first to allow random access on keys, which is O(n). > > > > Which is why I think this is a good addition to php-src. There's three > good > > reasons to include functionality in php-src (performance, ubiquity and > FFI) > > and this falls squarely into the first category. And now that we have > > fibers and need to worry more about multiple independent execution > streams, > > we also need to worry about multiple independent randomness streams. > > > > Regards, > > Nikita > > > > Thanks for the clarification, Nikita. > > The RFC says, "The Random class is a utility class that provides > functionality using random numbers." This led me to think it was a > wrapper that did not introduce new functionality. > > I can't find any discussion in the RFC on the independent randomness > streams provided by the OOP API. Go Kudo, can you update the RFC with > more information about this functionality? > > Cheers, > Ben > > --0000000000009c1ff105cb598f16--