Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:115981 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 69957 invoked from network); 7 Sep 2021 07:44:47 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 7 Sep 2021 07:44:47 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 6F79E1804DB for ; Tue, 7 Sep 2021 01:22:12 -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.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-ASN: AS15169 209.85.128.0/17 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 ; Tue, 7 Sep 2021 01:22:12 -0700 (PDT) Received: by mail-ej1-f50.google.com with SMTP id t19so18078082ejr.8 for ; Tue, 07 Sep 2021 01:22:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=u20JjV9fGMKIJ7J6BoRZNFWFPOnK1Cj5uQInI8Rf8vI=; b=GmmBSl7wo452clAiSHIST4ZMdJErWTQMdGDuwdyl4AHo8xVk4IfvVnUlSZUbA5X0iY 8fxM82FDScWSb3UEW1mE809b/ZypT2aMvSJ1Tk86iIzWAdPPrRAXcQcxeFTFC/huX4Uv 85ysuI13+XLJATLoBrDYC2UPtao5EwtMIE66S/ivfN+6RoJotmMPJFaMq/rK0w7HItwc Kl2SZ/g3TQ8mlAP9OFl39E5VsRsOtVnllxj3jbhg4aYJh2N/s7sT+vPWIhZAycJ7dB+4 4KA0kVrheW6uT0B+ivVtAr4pAYIUeJwIcczkQavV6+adqtRCIQQrOmuj+DxloVTeci0L F7IQ== 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:cc; bh=u20JjV9fGMKIJ7J6BoRZNFWFPOnK1Cj5uQInI8Rf8vI=; b=KMH+dsSCHOn3CHUMHlamSb1lFC4JJtNf2Kue8ePQOgfGteUAyZgRJclCLDOJKo40QT ExwZS9v90zvfRCc5ff403d5VqLS8VM0D7YcPPQG9ubShnGdEGwpwyN/Fuz5yEHzSr+z5 PRQ9bxcv2RftabGN2W4vsgpaOeZr5WGJAviguflukKlVc5PCy6kLBp/TlfzXScXa0Bz7 hvW12IneG7aDRm07RLiTk/oDAzxP+/jM2dDBw5Kbnkb6hwua0qNd4Jfa3Efs5rsR/1F7 faNxgxK3nVnrUTJcXsm8GERxUgCx87pMP6AEKp9dvXFwiuT5PL7XxxBcV6qZoAbn5p9g rvug== X-Gm-Message-State: AOAM530xy3EhYtxj91vIXgPBFY85S+rj7jhBKP+HGTkE12S2dUK5YVfY Z1qeDpbnKYAazsefgumpalHtw+WU/QqJvzeemNo= X-Google-Smtp-Source: ABdhPJy+hXEsquwCbNEOK7MuSxeQLfhfDcxSK2O4dHaeC56lB7at4Bm0eG+Pk/PLKoprGk4DM+6j7jDZ1yxWkDCQ1YQ= X-Received: by 2002:a17:906:6717:: with SMTP id a23mr16897979ejp.358.1631002925093; Tue, 07 Sep 2021 01:22:05 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Tue, 7 Sep 2021 10:21:49 +0200 Message-ID: To: Marc Cc: PHP internals Content-Type: multipart/alternative; boundary="000000000000fa570405cb637508" Subject: Re: [PHP-DEV] [RFC] Random Extension 3.0 From: nikita.ppv@gmail.com (Nikita Popov) --000000000000fa570405cb637508 Content-Type: text/plain; charset="UTF-8" On Sat, Sep 4, 2021 at 10:57 PM Marc wrote: > > On 9/2/21 5:10 PM, Go Kudo wrote: > > Hi Internals. > > > > Expanded from the previous RFC and changed it to an RFC that organizes > the > > whole PHP random number generator. Also, the target version has been > > changed to 8.2. > > > > https://wiki.php.net/rfc/rng_extension > > https://github.com/php/php-src/pull/7453 > > > > Hopefully you will get some good responses. > > For me (user land developer with no voting power) your RFC looks pretty :) > > Beside the abstract vs interface question I have some other notes: > > On the one hand you define "getBytes()" which returns a string and on > the other hand you define "shuffleString()" - is the first one a binary > string and the other a charset dependent string? I guess here > "shuffleString()" works on byte level and so it should be "shuffleBytes()". > > Why are there no default values for min/max on "getInt()" - It seems > unnecessary to me to pass min/max arguments if you are just interested > in a random integer or passing max as well if you are interested in a > positive integer only. > Because the default range is not obvious. For example mt_rand() without min/max will actually return only non-negative integers, so someone might expect $random->getInt() to do the same, even though it makes very little sense. $random->getInt($n) could be interpreted either as a number in $n..PHP_INT_MAX (if we just see it as leaving $max at the default value), or 0..$n-1 (a very common convention for single-argument random integer functions). Requiring both arguments makes the meaning unambiguous. Regards, Nikita --000000000000fa570405cb637508--