Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:118917 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 60320 invoked from network); 30 Oct 2022 12:28:59 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 30 Oct 2022 12:28:59 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 659731804AA for ; Sun, 30 Oct 2022 05:28:58 -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,T_SCC_BODY_TEXT_LINE 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-pl1-f182.google.com (mail-pl1-f182.google.com [209.85.214.182]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Sun, 30 Oct 2022 05:28:54 -0700 (PDT) Received: by mail-pl1-f182.google.com with SMTP id d24so8597254pls.4 for ; Sun, 30 Oct 2022 05:28:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :from:to:cc:subject:date:message-id:reply-to; bh=FR/DGuAo3nYx67kSHr/4VwCqb6U9gePG9AIjwZ5WoNw=; b=QfIsZi8ex/8CTIJKLhqGWMbQ919aCBYvqtiuveeUjG8uufbelRpX8D398m3I5vI0Hn 9s1vGHYyRzaIURKyRLPO0FE/hfMwT1EbArv/MnLXvd6cLb8EYjwdNBiFPXizGqoHxNTm ym2HsryrCEYJkPhd7kMx86g8SD5tVU0g4Xmfzi3aXUhZMgCSCU9KHv2+JpOly7ht4uLn LrOwhwZF5NuZfcJ1DSNydE6JitEgHhkwkdy/2Ux1gDbTUeYq7jx/jvrae6pVE2iivlft iA+3idZrT2SrjyqWaFDPIPKTjVB8/sBVplHbkh2cKZ3h+FFvZk10z/hCb2JudgremAuM ludw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=FR/DGuAo3nYx67kSHr/4VwCqb6U9gePG9AIjwZ5WoNw=; b=yM1VZreEj60swrBUnD3NmuWeDYJ7xfY6OuUAA0BjMYxMbdYFWXkq1xli6ISoNooEop ujL9EqFj/rXSj5xLKge09hmytIU4btJVqPkMGVY5JXoYbTvWuOJKqMWabyxP8uTHFMC6 I2IW8wzet9AKWKOmFJRB9BjvXGUg6L5vwlCLelMkvJEFJDvEwFl5WIaFpD9ILvPwV3ot mCjJUroM3XURZTKwdigSN/KOWmg93hjbTOFJq3pJ1xU9opCn9cPhv6Z2hOmfpqze/jrj vjTYjS4e4iJ+vwFvkkzpegGDXwhe9pcZrARJ8CFS8e3f8CaC0xItusfmkWpLcaZ/Y4do bX+w== X-Gm-Message-State: ACrzQf0sUqXDycj3/0qoM/ScnlzpDXK8WWVJVK+U2xI8vN3cJQdknhC8 AAOp94L1slQownXt1km3+i3cPcTH5P+i/QhB2zYvUj+7c5w= X-Google-Smtp-Source: AMsMyM5GtQ4bjZHC7NR4+osQ1BSxth/a6I3u306eGvjoY4eM96Ciutge5ySvvTM3l1Q+qAMdrZcjcm0KChhN/iWl238= X-Received: by 2002:a17:902:d503:b0:187:19c4:f9db with SMTP id b3-20020a170902d50300b0018719c4f9dbmr2423796plg.82.1667132933247; Sun, 30 Oct 2022 05:28:53 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Sun, 30 Oct 2022 21:28:42 +0900 Message-ID: To: PHP internals Content-Type: multipart/alternative; boundary="00000000000047949705ec3fa292" Subject: Re: [PHP-DEV] Pre RFC - Additions to the randomizer From: zeriyoshi@gmail.com (Go Kudo) --00000000000047949705ec3fa292 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 2022=E5=B9=B410=E6=9C=886=E6=97=A5(=E6=9C=A8) 6:44 Joshua R=C3=BCsweg via i= nternals : > Hi > > I would like to introduce a new method for the new Randomizer class [1]. > I would like to have a function that generates a random string for me > based on a given alphabet. This function is useful as a building block, > as many use cases require generating random strings with a specified > list of characters (e.g. random passwords, voucher codes, numeric > strings larger than integers) and implementing this in userland requires > multiple lines of code for what effectively is a very simple operation. > Furthermore the obvious implementation based on ->getInt() is > inefficient, as it requires at least one call to the engine per > character, whereas a 64 Bit engine could generate randomness for 8 > characters at once. > > I have opened a Pull-Request on PHP to demonstrate the implementation > [2] but I am unsure about the method name and decided for > `getBytesFromAlphabet()` but I am open for better suggestions. > > During code review Go Kudo requested that this goes through an RFC and > Tim D=C3=BCsterhus requested to handle multiple new methods in bulk. Tim > implemented a new method, which returns a random float value [3], since > that's non-trivial to do in userland and an equally useful building > block like my introduced method. > > Since the class into which this function is built is final anyway, the > methods can be built in with full backwards compatibility. > > I look forward to feedback from you! > > [1] https://wiki.php.net/rfc/random_extension_improvement > [2] https://github.com/php/php-src/pull/9664 > [3] https://github.com/php/php-src/pull/9679 > > PS: Since this is my first contribution, someone needs to give me karma > to open an RFC. My account name is `josh`. > > Cheers > > Joshua R=C3=BCsweg > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: https://www.php.net/unsub.php > > Hi I have read the RFC. I think the content is generally good and adequately compensates for the areas that could not be completed. I am skeptical only about getFloat(). The use cases are limited and seem somewhat excessive. Do you have examples of how this is supported in other languages? Regards Go Kudo P.S. It's been too long and I had forgotten everything about how to use ML. Apologies for replying directly to you. --00000000000047949705ec3fa292--