Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:112837 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 57558 invoked from network); 10 Jan 2021 20:57:51 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 10 Jan 2021 20:57:51 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id E01C41804F6 for ; Sun, 10 Jan 2021 12:35:21 -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=-0.7 required=5.0 tests=BAYES_05,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-ej1-f43.google.com (mail-ej1-f43.google.com [209.85.218.43]) (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, 10 Jan 2021 12:35:21 -0800 (PST) Received: by mail-ej1-f43.google.com with SMTP id g20so21958723ejb.1 for ; Sun, 10 Jan 2021 12:35:21 -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=aS0dmH7BfkWrqOWxbjzlkSE6P+nGBw3YsDdI/GoY0E0=; b=p7fjbQT8yR7VGOqsKW/uAwB3AsqIJ47InM+4bYjYzKzEfGkKbYJLR3Jf/N91EbnWZY J05/c7Ntjf+ZxilcSBw1bFZSHjAJcaoSLUlfAl1dK6RYjWQSKW/99FYRIMHsFfEjbZ3j kRXDmp9jCLTfywPjjVbTLs9Om3Wl0lE2m/nRb7/A5oY7cXBb8ncJVHXnFQH1o/a0EL3w rvMn0G5ZgD/x1v04zDCR9yfag/v9AkS+/TatFx1MvpPX0EECAc/BUkbgIR/wsfzz6TPj 1+L3WWItmNK9jnSikGIZTL70oUMnTWeo+V3FWGY4zxHkC7sGmP7xB+M0QOr5VwaS6whI Omow== 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=aS0dmH7BfkWrqOWxbjzlkSE6P+nGBw3YsDdI/GoY0E0=; b=sO5HBIT53fw1yR/1nd7BQXM1dcl5rxBwZ9e4EDA0fq6jkCgpK44QO0J1BxqNea7sMk trelLyIHSz6yr0FnsFEHoKO6tgZbeVg1YH4zKmxNHCxC64HE/DMKzjx+yFAq4i/bGEfA +oI3mSJJbpVFUI9kja/Tx59hNwU3LpeD3JNyBNELa80Z6XxbDQlORON6bBG2uh6tqNY/ YTezAhp9d/zgsYY+TMhHw1HgT+apSLSUcDIbgE3XHEcgQgrXq8AntSHmGxwwvxtABeSV Le7NsIwSLimEJepYs7f0Aj94xbkftlY30h+hQJWd/Wc9qsYq3aWCbWLbEviwqSMdBjno uIZw== X-Gm-Message-State: AOAM531havrjNYpnB7qHzdYWPiotHLWCFnZi9U+ljboXSAHg3V8TFbTM hnFio+lYeCcROqDNJSCxHbSY0Dq+zzxxOaC7A3pEi/Y49Asybg== X-Google-Smtp-Source: ABdhPJzToqXv1PK8TIsYGp+Q2vK0UW1munlimWEH6RQ86GJ3ZrCNs8XaSvPBWp1bQRyhFMb8LIYy8NMEhiYpERUkAeE= X-Received: by 2002:a17:906:22c7:: with SMTP id q7mr8691508eja.486.1610310918368; Sun, 10 Jan 2021 12:35:18 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: Date: Mon, 11 Jan 2021 05:35:07 +0900 Message-ID: To: internals@lists.php.net Content-Type: multipart/alternative; boundary="00000000000044717d05b891bacf" Subject: Re: [RFC] Object-scope RNG implementation From: zeriyoshi@gmail.com (Go Kudo) --00000000000044717d05b891bacf Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi internals. I implemented Type II, which was pointed out by Nikita and fixed. https://github.com/zeriyoshi/php-src/commit/5ff8882a8fbfaf4ffd5cc42fb5853c4= a1a00c182 This is much smarter and simpler than Type I, but the implementation is more complex (partly due to my lack of knowledge). It contains the complete implementation except for MT19937, and the userland implementation and the native implementation are completely separated internally. In other words, cannot inherit from native classes. Also, I found during the implementation that the array_rand() function can get stuck if you implement an RNG that always returns a fixed result, for example. ``` class FixedNumberGenerator implements \RNG\RNGInterface { public function next(): int { return 1; } public function next64(): int { return 2; } } $rng =3D new FixedNumberGenerator(); $array =3D range(1, 100); array_rand($array, 2, $rng); // Oops, stucked. ``` This can be somewhat dangerous and should be kept in mind when implementing it. There has been no positive or negative feedback on this suggestion, and frankly I am worried that I am continuing to act in an unpleasant manner. 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 > --00000000000044717d05b891bacf--