Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:114455 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 84013 invoked from network); 12 May 2021 20:19:12 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 12 May 2021 20:19:12 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 667E61804BD for ; Wed, 12 May 2021 13:27:19 -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,NICE_REPLY_A, 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-wm1-f51.google.com (mail-wm1-f51.google.com [209.85.128.51]) (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 13:27:18 -0700 (PDT) Received: by mail-wm1-f51.google.com with SMTP id o6-20020a05600c4fc6b029015ec06d5269so3667046wmq.0 for ; Wed, 12 May 2021 13:27:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-transfer-encoding:content-language; bh=gwfNOzXIwQ8U1a9ks6keVtuz1KHUmPxw+22crV8o6vs=; b=aB5hWLizHZXV2h9XAyFjm/rRLgnUOiUK1to5klTTQcmkMQK6mFXfP7/IKt6OApPCzF 3sQ2GyCv+IlgW7fAjqEM+4fXyvL9o4hzDqgi9zswm1uzhWAfjwMm+SJrcOXmefg9V5xg wE1ctugvgyodvXho3AZBWGRj8jKm14CXRypZ8K2lEfLEJdd40wUc3C5/Y715dJ4x6TM0 VOgu1Ftw5yRK3XKqm0IN650x9/TVLsWkuZJ0ia7ittZ/iHGFoVBKKoKdUYsGpn2M5UrO cwZJf67bfrpeLgZFt7k6cfd90HUcsBsFgwcedoaypVwh45VPQpbUEwJfqVQAkanmePGW Oynw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=gwfNOzXIwQ8U1a9ks6keVtuz1KHUmPxw+22crV8o6vs=; b=glOPzI3iN79ob8C6AAgZ0fN48COMl01jKYjhZTRt8ulHkHsJjByIU19FJerw3CA+vC N5WultN1Xp9Cvw60EbTmL2gO+xGJji9lulO0CAsxWAKSPm2NSrqMsEkIHB6VykZ9ocXW RgCd2k7de+J5xH/yCKijJszaHLkDpQGVzEpydtGt2UdgKgy2vpf661WbddFT0LVWWB5B xHtZJGLz3UXFSZ8s59ASt0+u2DIzaZSbFjcLFF6Xhru8qW71Jnr4HI/bM/9XUg89cLob s6EM1GVfHAC1KpoowrJm65e4knJg0oWsMBSqcFP5QWJOPFCxvqUtSEYQDDXZ6qqO4q73 eWGw== X-Gm-Message-State: AOAM532tjrJCAe/bYtvWUuSpqkdzr2Vxkt2WeHpM/zwnxpyEFHZNX3fE 94BW4V2D5Lc2BtvKJoIhkWWUv8fdEe0= X-Google-Smtp-Source: ABdhPJzu+HR7BHfEHP4coNWfXwH4Qw4t3hewqkCI6gLrnfQJbbv9aVaac1paUxbhEvng/XUGJkjrJQ== X-Received: by 2002:a7b:c092:: with SMTP id r18mr37358410wmh.51.1620851236757; Wed, 12 May 2021 13:27:16 -0700 (PDT) Received: from [192.168.0.22] (cpc104104-brig22-2-0-cust548.3-3.cable.virginm.net. [82.10.58.37]) by smtp.googlemail.com with ESMTPSA id y14sm749887wrr.82.2021.05.12.13.27.15 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 12 May 2021 13:27:16 -0700 (PDT) To: internals@lists.php.net References: Message-ID: <014b544c-e879-c8a9-d59e-2d8889e4370e@gmail.com> Date: Wed, 12 May 2021 21:27:12 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.10.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-GB Subject: Re: [PHP-DEV] Discussion: Object-scoped RNG From: rowan.collins@gmail.com (Rowan Tommins) On 12/05/2021 15:39, Go Kudo wrote: > I haven't decided whether to include it in the next RFC, but we think we > need to deprecate all functions that use RNGs with global state (shuffle(), > array_rand(), str_shuffle()) in the future. I don't understand why that would be necessary or helpful. The majority of code using those functions does not need repeatable or configurable results, and would not benefit from a more complex API. If you're just deciding which order to show the user some cute pictures of cats, shuffle($array) is much more appropriate than (new RNG\Randomiser(RNG\MT15593))->shuffle($array) or whatever the API ends up looking like. I can however see an argument for deprecating srand/mt_srand: if you want a reproducible pseudo-random sequence, create an object to manage its state; if you don't, leave the engine to manage it for you however it wants. The way the seed was initialised would then be entirely an implementation detail, just like the algorithm, which already changed in 7.0. Regards, -- Rowan Tommins [IMSoP]