Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:94006 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 32877 invoked from network); 15 Jun 2016 13:04:41 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 15 Jun 2016 13:04:41 -0000 Authentication-Results: pb1.pair.com header.from=j.boggiano@seld.be; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=j.boggiano@seld.be; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain seld.be designates 74.125.82.42 as permitted sender) X-PHP-List-Original-Sender: j.boggiano@seld.be X-Host-Fingerprint: 74.125.82.42 mail-wm0-f42.google.com Received: from [74.125.82.42] ([74.125.82.42:37728] helo=mail-wm0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 0A/60-27860-76251675 for ; Wed, 15 Jun 2016 09:04:41 -0400 Received: by mail-wm0-f42.google.com with SMTP id a66so23832981wme.0 for ; Wed, 15 Jun 2016 06:04:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=seld-be.20150623.gappssmtp.com; s=20150623; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-transfer-encoding; bh=wIuZlE5Xo7N7u66N+e9VfDsPG+vEP3R7kSzuooD1Ee4=; b=MacXcxF29fEeHsikmCsAQXR5CMl/S6EhPeqVIlB+ku7GAltN+v5p7H+Wlf6CcMVu69 KAZIFjGVXUFoqJv06wytuAgzIMtoiZafYWcjrB2L4iR7BkhjufJYfnPk9mfKEJvzhSqE aaU7EByaFjVBTt4XTYoxLjMlkkETkXC8dGkqVnOxqwVMwwIzxzdMmXgyVP1kESwKU1S1 /onAzKW4oMCOWsj/qVOqVfwlLe7iS4HzNVvS8Tyfi4UUJtKsrsxHhaOVhsld5j7Xsk45 HowSUo48qDsI3P4yMyMFKW/NfHk/JUXryuuddEG4bqFUUXPHb/uisZ0cD8Bk47RcNyo5 ABVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=wIuZlE5Xo7N7u66N+e9VfDsPG+vEP3R7kSzuooD1Ee4=; b=V+TBBzB2TOtm776viCFToavaj/nQJINArUr+SiN4kEJ2AEtfrOvi2cK/SjGFUzAlZH nXwvV2EXeMO2LlVkGs3Hj+yHCCVEkxO3WlUQiqQS4VtcmsaxY+3shcLGLYmSMb+oqJwg qDegM8oNeNqfSCki4Y74RNsuKYtU8ceuY1iq7B8JYDzogffUachtEw7pNHWMj9rf7Rar 84lbmB0burjAi3A+AzKdTEevlSLD2O5OOKqikikJwOoM2uY0iXm687YODvk0nLd0gkoS P5B7fTiXwXKUGdkS7ndbMeWur/zs7oujV06Xdr5QdZyp4FNJpJZwPenE3zndCO3+vStq OLUA== X-Gm-Message-State: ALyK8tIE5NgFLHGfNzJIsV/djF8BPGo77NrsJUYtMSSLPQ+g8gGIRCBcLQaIkdR7ZAwzUA== X-Received: by 10.28.157.199 with SMTP id g190mr12057990wme.2.1465995875851; Wed, 15 Jun 2016 06:04:35 -0700 (PDT) Received: from [192.168.0.2] (cpc74585-lewi13-2-0-cust978.2-4.cable.virginm.net. [82.25.75.211]) by smtp.googlemail.com with ESMTPSA id r16sm4140674wmb.23.2016.06.15.06.04.31 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 15 Jun 2016 06:04:31 -0700 (PDT) To: internals@lists.php.net References: <0df5eed8-5240-8dfe-f7f3-acf551eadb6d@thefsb.org> Message-ID: <8e5d61e4-f43a-bc6b-486e-79a783ee591a@seld.be> Date: Wed, 15 Jun 2016 14:04:36 +0100 User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.1.1 MIME-Version: 1.0 In-Reply-To: <0df5eed8-5240-8dfe-f7f3-acf551eadb6d@thefsb.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] [RFC] RNG fixes From: j.boggiano@seld.be (Jordi Boggiano) On 15/06/2016 13:41, Tom Worster wrote: > int mt_rand ( $mode = MT_RAND_COMPAT ) > > int mt_rand ( int $min, int $max, $mode = MT_RAND_COMPAT ) > > MT_RAND_COMPAT = 1 > > MT_RAND_MT19937 = 2 > > A PHP user needs to make the right choice of what to use in their > situation. A technical description of the modes would be confusing and > unhelpful to most users. I have no idea how to document this simply, > honestly and accurately, and without jumping to conclusions about > suitability. > > This is why I think a compat/correct mode switch doesn't improve PHP. > It's inconsistent with the spirit set out in the preamble of "PHP RFC: > Your Title Here"[1]. > > [1] https://wiki.php.net/rfc/template > > Similarly, the $mode arg allows us to add MT_RAND_XOROSHIRO128_PLUS or > whatever (interesting to some of us, more "modern", perhaps arguably > more "strong" or are otherwise "better") aren't improvements to PHP > unless users are asking for them. Just a thought here, if the goal is to provide a better interface, wouldn't it be better to use OO for this? Not because OO is better, but because it would avoid having problems if two mt_rand-using pieces of code are executed concurrently. Something like this: $gen1 = new SeededRandom(MT_RAND_MT19937, 23); $gen2 = new SeededRandom(MT_RAND_MT19937, 23); $gen1->rand(); // or get()? generate()? $gen1->rand(); $gen2->rand(); // returns the same as the first call as both use seed 23 With the current situation, if you add a library that relies on mt_rand you can suddenly break your ability to get consistent numbers. Cheers -- Jordi Boggiano @seldaek - http://seld.be