Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:114449 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 57233 invoked from network); 12 May 2021 15:35:45 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 12 May 2021 15:35:45 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 4FB8B1804D9 for ; Wed, 12 May 2021 08:43:47 -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=-0.5 required=5.0 tests=BAYES_05,HTML_MESSAGE, SPF_HELO_NONE,SPF_NONE autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from darkcity.gna.ch (darkcity.gna.ch [195.49.47.11]) (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 ; Wed, 12 May 2021 08:43:46 -0700 (PDT) Received: from smtpclient.apple (unknown [IPv6:2a02:1205:502d:fa80:b5e2:d4ee:37d9:a54a]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by darkcity.gna.ch (Postfix) with ESMTPSA id 6BEF5150E92D for ; Wed, 12 May 2021 17:43:43 +0200 (CEST) Content-Type: multipart/alternative; boundary="Apple-Mail=_CBF057A6-5263-495D-9988-C51327210AE9" Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.80.0.2.43\)) Date: Wed, 12 May 2021 17:43:42 +0200 References: To: php internals In-Reply-To: Message-ID: <85544020-CC01-4AA0-941E-73ED95E496A6@cschneid.com> X-Mailer: Apple Mail (2.3654.80.0.2.43) Subject: Re: [PHP-DEV] Discussion: Object-scoped RNG From: cschneid@cschneid.com (Christian Schneider) --Apple-Mail=_CBF057A6-5263-495D-9988-C51327210AE9 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii Am 11.05.2021 um 23:20 schrieb Larry Garfield : > 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. >=20 > So, at first pass, an API could be as simple as (pseudocode): >=20 > class RandomSequence { > public function __construct(int $seed =3D time(), $algorithm =3D = 'some_default') { ... } >=20 > public function next(): int { ... } > } >=20 > And that's it. That's nice and simple and predictable to use. Would the generated values fill the whole int range, i.e. 64 bit on = modern systems? And would it make sense to add max and min for the generated values like = we have with random_int()? Because mapping arbitrary int values to a specific range is error-prone: = Just using modulo leads to bias in the resulting values. - Chris --Apple-Mail=_CBF057A6-5263-495D-9988-C51327210AE9--