Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:112592 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 90746 invoked from network); 22 Dec 2020 15:36:18 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 22 Dec 2020 15:36:18 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 0E18D180538 for ; Tue, 22 Dec 2020 07:09:01 -0800 (PST) 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-Virus: No X-Envelope-From: Received: from mail-lf1-f47.google.com (mail-lf1-f47.google.com [209.85.167.47]) (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 ; Tue, 22 Dec 2020 07:09:00 -0800 (PST) Received: by mail-lf1-f47.google.com with SMTP id o19so32802033lfo.1 for ; Tue, 22 Dec 2020 07:09:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=de69RTJPqRZklNNmVGMC0qeDAe/9zhONi0XCiWLeBOs=; b=tsvan46UXLMzGjs/IbitUK5I08aGOWXHJWR/rAT4wYwG7VNMK4/Y3ReXu8yRtBYFMj jthLt/UzLfrMI5LWtUQPDVPWCtiDPDqSD3wc5L/t4DJe69G0oQm9F5preVwdenV97H5q N8HLUg7mASavB6wXH8TF6uuLJQiqhMG7lX+WsZRrExfBDQ74wHR2dQs7pInIyK8Am2qW DHG0U60H+A2CB7SGEWudo5HKjXH5hF9WYEJKmfIPr3BjgrIEg/96c59obizRuHlRxky9 aAHbZFTJ4/96NGSbKxuz4FVRBJcuQsxXYTeUBP9zmJkExsOxQC9KArW9vVZjSApIed8i ATJw== 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=de69RTJPqRZklNNmVGMC0qeDAe/9zhONi0XCiWLeBOs=; b=dbYMui3nZOZCNYAOt+vVa3snSD6axMWLIXgsiq/yZT9LHECv5h8o+DEQfGUM0WXUAA 2gkoMt2EST+n8I58+sfcHipbxpSYvYPsp942Bc4wmHVjb7PC8ps5rT0bbOMsdmM2vUUP Kr3S38hYvDpYZM2iNmKjKlX/erwqQXrSzCpOX2RroVreoJU7qPTqE0nFsVaf6YqDXba3 ttW5qUFGAoKmRBAx9l6fL41DRb0uobz14eoOfTHCVhlazMEe7+9GYkdDAsgfZcAvQU0q eP/LWAzY5Gln0EaCyp9teiu55+fqhvLIJIP0TOSdxOSbSIYxlkV+qVpjHpewhFj8dPC9 QQrQ== X-Gm-Message-State: AOAM533Xl14EDVJga1dXPXC0zeAoCKiNmcnLxs1jpwwqeE4RH+ZLZ/ty yIbPAbQE892xfTOFB2CeAOvOBvpJXYO3544I8SFnZ3sSmXaQww== X-Google-Smtp-Source: ABdhPJwFTO6bxGKf6md2o1/8q75WiLgoD8n/6Ka0sXQReyukG3OxNFBFe6VUu6oM4m5X1muuWgiYDdDa6oIub1xKLLs= X-Received: by 2002:a17:906:1f8e:: with SMTP id t14mr20405428ejr.350.1608649342299; Tue, 22 Dec 2020 07:02:22 -0800 (PST) MIME-Version: 1.0 References: <1f319ee0-e5e2-3d5e-2b8c-4d3c073f98e6@gmx.de> In-Reply-To: Date: Wed, 23 Dec 2020 00:02:09 +0900 Message-ID: To: Max Semenik , internals@lists.php.net Content-Type: multipart/alternative; boundary="0000000000009e301105b70edcbd" Subject: Re: [PHP-DEV] Re: Improving PRNG implementation. From: zeriyoshi@gmail.com (zeriyoshi) --0000000000009e301105b70edcbd Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Thanks. I have edited the RFC based on your question. > Method names: you don't need to emulate the conventions from non-OOP code, e.g. string_shuffle() --> strShuffle and array_rand() --> arrayRand(). Use a more naturally readable convention like shuffleString(). As mentioned in the RFC, it is intended for interoperability. However, you may be right that we should forget the past and aim for a better implementation. > Do you have evidence of widespread demand for this functionality? Usage statistics for the userland implementation you mentioned[3] don't look that hot. A difficult problem. At least for PHP, which is a web-oriented language, there may be little demand for it. In my opinion, an object-scoped implementation will be needed in the future. For example, there are currently proposed implementations of Fiber, which will certainly make global state unpredictable. Swoole extension is also a concern, although I am not familiar with this. Regards, Go Kudo 2020=E5=B9=B412=E6=9C=8820=E6=97=A5(=E6=97=A5) 23:09 Max Semenik : > On Sun, Dec 20, 2020 at 6:45 AM zeriyoshi wrote: > >> Thanks cmb. I have created a first draft of an RFC. I think I've covered >> all the necessary requirements, but I'd like to know if there are any >> problems. >> https://wiki.php.net/rfc/object_scope_prng > > > A few IMHO comments: > * Namespaces are controversial. There were multiple discussions and RFCs > about introducing them for new functionality but nothing came out of it. > Still probably worth adding an option for \PHP\PRNG to the vote, or > something like that. > * The "Which set of PRNGs should be provided as standard?" vote seems > vague to me. Are you proposing to add only one algorithm? Why? Also, the > adding just interfaces option makes no sense because there's Composer for > things that don't require a C implementation. > * "One possible solution is to implement the PRNG in pure PHP. There is > actually a userland library [1], but it is not fast enough for PHP at the > moment. (However, this may be improved by JIT)" - this definitely needs a > comparison because implementation in C is only needed for performance > reasons. > * Method names: you don't need to emulate the conventions from non-OOP > code, e.g. string_shuffle() --> strShuffle and array_rand() --> > arrayRand(). Use a more naturally readable convention like shuffleString(= ). > * The return value in "function shuffle(array &$array): bool" means that > if something goes wrong, callers will have no idea what it is. Just throw > an exception. > * If the classes are namespaced, don't prefix their names, > e.g. PRNGInterface --> RandomGenerator (yay, so many opportunities for > bikeshedding!) > * Perhaps it's worth mentioning other languages using this pattern, e.g. > Java[1] and C#[2]. > * Do you have evidence of widespread demand for this functionality? Usage > statistics for the userland implementation you mentioned[3] don't look th= at > hot. > > ------ > [1] https://docs.oracle.com/javase/8/docs/api/java/util/Random.html > [2] https://docs.microsoft.com/en-us/dotnet/api/system.random?view=3Dnet-= 5.0 > [3] https://packagist.org/packages/savvot/random > > --0000000000009e301105b70edcbd--