Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:114424 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 33970 invoked from network); 11 May 2021 21:13:34 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 11 May 2021 21:13:34 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id C01381804F4 for ; Tue, 11 May 2021 14:21:25 -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.6 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL, SPF_HELO_PASS,SPF_NONE autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from wout2-smtp.messagingengine.com (wout2-smtp.messagingengine.com [64.147.123.25]) (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, 11 May 2021 14:21:25 -0700 (PDT) Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id 3BFB81219 for ; Tue, 11 May 2021 17:21:23 -0400 (EDT) Received: from imap8 ([10.202.2.58]) by compute4.internal (MEProxy); Tue, 11 May 2021 17:21:23 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=vGArgN ZaMAhTQ2TFgxiqR+j0sTFS2dB6vQYx/sQw9sc=; b=vczp8QgusoAS6PDTC1pLVT yp0xgRXyxbPEKJpiJkkq5jRje5u7xMUk/aiuTXIqr7Y5oUlK2ij8zAPbxU0veUwL 3Xd60cdC/qZIXZj3Qh5nZIPEQFiZLC8YfaJsBby8kVpLavoQLQi7l44X7rk9sVr4 5jSem4fVaNzJVqjbHu1MHJg4P+PmPBw2J5DIK+lFbV5HBM3YiWBRoqrPM87Oa01B gADygYVSKQ5q0vbD0g551KOJ2ck9I5ZJWi6OAF4jTzAadcCC/yNV3fsY31Nwd8IV ZYx7uibhmmWphXOznrXprF6SUpR3lpWiJq/OduyOIZAdaqVbsNzjz+PLt0+2oF7g == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrvdehtddgudeiudcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefofgggkfgjfhffhffvufgtsehttdertderredtnecuhfhrohhmpedfnfgr rhhrhicuifgrrhhfihgvlhgufdcuoehlrghrrhihsehgrghrfhhivghlughtvggthhdrtg homheqnecuggftrfgrthhtvghrnhepgeefffekleetgfekleegleffffdujeejvedvjedt leekuddufeelleevffeuheejnecuffhomhgrihhnpehphhhprdhnvghtpdgvgihtvghrnh grlhhsrdhiohenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhr ohhmpehlrghrrhihsehgrghrfhhivghlughtvggthhdrtghomh X-ME-Proxy: Received: by mailuser.nyi.internal (Postfix, from userid 501) id 95DAA3A04FE; Tue, 11 May 2021 17:21:22 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.5.0-alpha0-448-gae190416c7-fm-20210505.004-gae190416 Mime-Version: 1.0 Message-ID: In-Reply-To: References: Date: Tue, 11 May 2021 16:20:59 -0500 To: "php internals" Content-Type: text/plain Subject: Re: [PHP-DEV] Discussion: Object-scoped RNG From: larry@garfieldtech.com ("Larry Garfield") On Tue, May 11, 2021, at 7:57 AM, Go Kudo wrote: > Hi internals. > > I previously proposed an object scope RNG implementation inside. > However, the RFC was rejected after a vote. > > https://wiki.php.net/rfc/object_scope_prng > > Vote: https://externals.io/message/113888 > Discussion: https://externals.io/message/112819 > > As per my previous proposal, PHP is currently in a very unclear state > regarding the random number implementation. > > So I would like to ask a few questions. > > - Do you think that PHP needs an object-scoped random number > implementation? And why? I don't work in areas that would tend to need such a thing, but other people do so I have no objection to it existing, as long as it's well-designed. > - If the API in the previous RFC was improved and voted on again, would you > be willing to vote for it? Yes. > - What issues do you think should have been resolved between proposal and > ballot in the previous RFC? > > I would like a variety of opinions. 1) Get rid of all of the functions. Object-scoped means... you just have an object with methods on it. That's it. 2) Don't force people to use a subclass with an incomprehensible name. In this case, a single class with a constructor parameter that specifies the algorithm to use is far superior. Possibly that parameter could be an object conforming to an interface if you really want, as long as the default is reasonable so most people never have to use it. 3) Perhaps it should be named RandomSequence or similar? It's not truly generating random numbers. It's generating a repeatable but difficult to produce sequence off of a seed value. That's not the same thing as random_int() et al. So, at first pass, an API could be as simple as (pseudocode): class RandomSequence { public function __construct(int $seed = time(), $algorithm = 'some_default') { ... } public function next(): int { ... } } And that's it. That's nice and simple and predictable to use. 4) As Levi said, we have a new policy document on namespace usage. This is a good first application of it. --Larry Garfield