Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:112978 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 83068 invoked from network); 25 Jan 2021 01:25:04 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 25 Jan 2021 01:25:04 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 0133B1804CF for ; Sun, 24 Jan 2021 17:06:09 -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-lj1-f178.google.com (mail-lj1-f178.google.com [209.85.208.178]) (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 ; Sun, 24 Jan 2021 17:06:08 -0800 (PST) Received: by mail-lj1-f178.google.com with SMTP id p13so13344160ljg.2 for ; Sun, 24 Jan 2021 17:06:08 -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=Cs8VIlfZ6oAnpNheYtrsKwKkFb1xpAXX0jHIl2D7kSQ=; b=ab2EqPQnZEMn8K673gxe0oyXmto07vJfB82JsnJulTCtp41WhjF2O9UK9Z/wnqgVLZ eL9nNih9a30GYWUpHrnpk8Gp39XfW+5z3M01LnJa3OlJBIS3iEdEuTP/JGhwdDYClcYb mgplzXNj45hFRSoPV92heulUB+XwZfkkcBwLUg5QHyF1LUTmMO4NBFCIDlt9tM+Swksm sTPwr9wmmB/8Dy0jDAaRYLJK3WBFNYL4Z5r03FGvlKiysBPV5M9dJPMmYwR58h/HkAIE m1IVsieAk+ZGKdcoL5jNDKJ4IJ18FXCYQGjA7z0buNMLHP4TNWozfTJBtr3GALv9dilw DT2A== 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=Cs8VIlfZ6oAnpNheYtrsKwKkFb1xpAXX0jHIl2D7kSQ=; b=VDCWURb261pIvmwvKan3FBybfBC7tIflIaOt/d+J62ve/v3Lp2dvDzixEPcH+Or6/O irAJez9Bom1IaUDvslGRpAD812Cso133gsGQQNSVYy6fgg+LQgZ1JjyhfA/ZTwXbfAf1 bQUdZgSZCB/WPR8r40k7HjilK2/75UJRmvlel7Xfuo4SJICxCtHD9rn1IUrnNPACdokf RFT8bhnkTAJP8NGuOljUcRXiewMuytiHmez/rFlLSjt5wEawjHvCrA9U3vq1b9soNE39 c7wKZuqytn15EoOfe2aMVLRNupzHU/icpgjO7gfTQsoqUUqjOAHlZtxGP/jY6RXdw1OM qlkQ== X-Gm-Message-State: AOAM5337aTOjG3qQ9Ek0pwePLPFkow1zs3McTtYyJA28x1XVUpsEoIfP 2zH5avtLZ/7DX73S9hyoAuZZc0rsFLHmetN9VvTdhNLY9k84Hg== X-Google-Smtp-Source: ABdhPJwP0wxG+Q6oSO30O5U/P9th89gpqwG3uXbI5kA8pxFPI29GuYM4KvcNibAHjFIm5A1S+xYFWdxlLCa3p+a4edw= X-Received: by 2002:a2e:97cc:: with SMTP id m12mr634110ljj.343.1611536764207; Sun, 24 Jan 2021 17:06:04 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: Date: Mon, 25 Jan 2021 10:05:53 +0900 Message-ID: To: internals@lists.php.net Content-Type: multipart/alternative; boundary="0000000000005f871b05b9af2465" Subject: Re: [RFC] Object-scope RNG implementation From: zeriyoshi@gmail.com (Go Kudo) --0000000000005f871b05b9af2465 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi internals. RFC has been updated to 1.3 and implemented. https://wiki.php.net/rfc/object_scope_prng The main changes are as follows: - `RNG\OSRNG` has been renamed to `RNG\OS`. This was too verbose. - `rng_rand()` has been renamed to `rng_int()` and the arguments `$min` and `$max` are now required. - `RNG\RNG64Interface` has been removed and `next64()` is now included in `RNGInterface`. - PHP code does not depend on the size of int. Even if it contains a 64-bit implementation, it will work fine on 32-bit PHP. Libraries should always consider the 64-bit environment. - To solve various problems, the `rng_next()` and `rng_next64()` functions have been added. - `rng_next64()` throws a `ValueError` exception when called in a 32bit environment. The current phpstub is as follows: ```php function shuffle(array &$array, ?RNG\RNGInterface $rng =3D null): bool {} function str_shuffle(string $string, ?RNG\RNGInterface $rng =3D null): stri= ng {} function array_rand(array $array, int $num =3D 1, ?RNG\RNGInterface $rng = =3D null): int|string|array {} function rng_bytes(RNG\RNGInterface $rng, int $length): string {} function rng_int(RNG\RNGInterface $rng, int $min, int $max): int {} function rng_next(RNG\RNGInterface $rng, bool $unsigned =3D true): int {} /** @throws ValueError */ function rng_next64(RNG\RNGInterface $rng, bool $unsigned =3D true): int {} ``` On the other hand, there are still the following problems - If `next64()` method is called directly in a 32-bit environment, it will produce unintended results. - This can be avoided by using `rng_next64()` in RFC 1.3. As with the various internal interfaces, direct method calls can be deprecated. - Namespace. `RNG`, `PHP\RNG`... etc - Interface naming. `RNGInterface` may be a bit redundant. `NumberGenerator`, etc? We are looking for feedback on these problems. 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 > --0000000000005f871b05b9af2465--