Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:112922 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 6841 invoked from network); 18 Jan 2021 16:49:22 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 18 Jan 2021 16:49:22 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 647A91804C6 for ; Mon, 18 Jan 2021 08:28:52 -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_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from mail-ej1-f50.google.com (mail-ej1-f50.google.com [209.85.218.50]) (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, 18 Jan 2021 08:28:51 -0800 (PST) Received: by mail-ej1-f50.google.com with SMTP id ke15so16830508ejc.12 for ; Mon, 18 Jan 2021 08:28:51 -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=+DSHABzgXXpGW/YgUJ6tPlg67er5w8AOmcEpZsaLii8=; b=l0jwMw+kiTcs7lkiWXoH95eIMY3T4f5kCnG2oU5tVpJJITjrwZ+iTwpHenfwVny/nr Qbbo9uK7DFi/+or0Dck8iGp8Vz4nmu92SbJF1ZBS4KzuUfp2p7Slcy0RxrD9WltAmlU8 7sF2pftKT63EzKdDB0yfLHkD8pEvIPsOrr+1mqKGfLlNLPqeqXG4/6VVRJqKaIRGEHRA raO+meG48E9UkVpIuHvl0hfz/CYgLK5onZQuNxYKeeRPvJx/U7J66MG3PJz5v3GqoLS9 rWOB4djl4rnsCOPVuXwAQe4PFJEotXBVsJzPX/9nTWQfGBsegtaMnlrW1i7JsxzWpYfl Aq4w== 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=+DSHABzgXXpGW/YgUJ6tPlg67er5w8AOmcEpZsaLii8=; b=qzvJNEl2pv9XR/eQXgkY54XUa9a/sdzc7iGGFmsCOGSTPS52eQXZshsK/At0w295Xe QH3hMcahUheKeYh7MAaqeKmKOoEaFqpyBUq6HJ47eWQAELHqgzcGfxXxTjyuWv5TA5/A f10xUEqXWaUrbMu1MYnwbUPKbT9PYc1AfvprRuOC7dAyHnp84jIkNHjwXAq+/3silcCY aczhtNtyfQfnI3LHZzzoVyC2iY2vaK602pZXIhVkjqhxNUyD2dz82QBvesGRCxg+nmeL yEn5ZGiAbXZQL8ISf52mkWX7eCBmrWiE537ISVz38hLxBFEZ7/Tc2i63wd5dQRoOnoJP YLBw== X-Gm-Message-State: AOAM530K0eOfW9joh8dXhto+yQSFuViTKFCdqNjSK51qjDn9g46qidXx W6n51/GwVthe6+VQDK3z/9/ZqTkfDuRCrnyCTBZliYky/cevcw== X-Google-Smtp-Source: ABdhPJyRmg5mZrI7qKMLyiE6Mk15hPxJ9noRgS3qAh7lV10q28aVMILX9mzyi42FVA8pA3XGHTY0JwIeGDKQX9esun0= X-Received: by 2002:a17:906:2681:: with SMTP id t1mr322898ejc.29.1610987328043; Mon, 18 Jan 2021 08:28:48 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: Date: Tue, 19 Jan 2021 01:28:37 +0900 Message-ID: To: internals@lists.php.net Content-Type: multipart/alternative; boundary="0000000000006d002605b92f3714" Subject: Re: [RFC] Object-scope RNG implementation From: zeriyoshi@gmail.com (Go Kudo) --0000000000006d002605b92f3714 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable RFC and implementation updated. https://wiki.php.net/rfc/object_scope_prng https://github.com/php/php-src/pull/6568 > MT19937 returns a signed 32bit number as a result of the `next()` method; the mt_rand() function returns a bit-shifted unsigned 31bit number, so the results are not identical. The `rng_range()` function has been renamed to `rng_rand()` and returns an unsigned 31-bit integer like the `mt_rand()` function if only the $rng argument is received. ```php mt_srand(1234); mt_rand() =3D=3D=3D rng_rand(new \RNG\MT19937(1234)); // true ``` This allows to completely replace the `mt_rand()` function with the RNG\MT19937. I said I wanted to initiate a vote, but there seems to be too much discussion missing for that. I'd like to wait and see for a while. Regards, Go Kudo 2021=E5=B9=B41=E6=9C=8817=E6=97=A5(=E6=97=A5) 20:02 Go Kudo : > Updated the RFC and fixed the implementation. > Also made some additions to the RFC about when this feature might be > useful. > > RFC: https://wiki.php.net/rfc/object_scope_prng > Implementation PR: https://github.com/php/php-src/pull/6568 (All CI > passed) > > The main points are as follows: > > - The implementation now meets all requirements. (maybe) > - Implemented MT19937, which is compatible with PHP standard MT. The > consistency of these is ensured by tests. > - The implementation is now what we used to call TypeII. > - All RNG implementations can now be inherited like regular classes. Use > faster calls only if the class is an internal class. > - The implementation has been heavily modified and the quality of the cod= e > has been improved. > > Currently, there are a few concerns: > > - MT19937 returns a signed 32bit number as a result of the `next()` > method; the mt_rand() function returns a bit-shifted unsigned 31bit numbe= r, > so the results are not identical. > - You can get the equivalent result with `$rng->next() << 1 & > PHP_INT_MAX`, but maybe you should have a `nextUnsigned31()` method. > - Currently, the test uses `$rng->next() << 1 & PHP_INT_MAX`. > - The implementation of MT19937 is redundant. This can be merged. > > Anyway, I think the code is finally ready for review. > Once that is done, we will start voting on RFCs. > > Regards, > Go Kudo > > 2021=E5=B9=B41=E6=9C=889=E6=97=A5(=E5=9C=9F) 19:00 Go Kudo : > >> Hi internals. >> >> I think I'm ready to discuss this RFC. >> https://wiki.php.net/rfc/object_scope_prng >> >> Previous internals thread: https://externals.io/message/112525 >> >> Now is the time to let me know what you think. >> >> Regards, >> Go Kudo >> > --0000000000006d002605b92f3714--