Re: rand(), mt_rand() and limits
| From: | Yasuo Ohgaki | Date: | Sun, 11 Jan 2015 23:57:12 +0000 |
| Subject: | Re: rand(), mt_rand() and limits | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-80388@lists.php.net to get a copy of this message | ||
Hi Andrea,
On Mon, Jan 12, 2015 at 7:12 AM, Andrea Faulds <ajf@ajf.me> wrote:
> * Get rid of rand(), srand() and getrandmax()
> * Rename mt_rand(), mt_srand() and mt_getrandmax() to rand(), srand(),
> and getrandmax() but add mt_* aliases for backwards-compatibility
> * Make mt_srand() and srand() do nothing and produce a deprecation notice
> * Use a 64-bit random number generation algorithm on 64-bit platforms
> (or invoke the 32-bit generator twice)
>
I like your proposal in general.
However, I object removal of srand.
Game programmers need "the same random sequence" on occasion.
There should be srand to get the same sequence for repeatable behaviors.
rand()/srand() may be renamed to sys_rand()/sys_srand() (or whatever
suitable name for them) in case user needs system random sequence
for whatever reasons. I don't insist to keep system's rand/srand, though.
Regards,
--
Yasuo Ohgaki
yohgaki@ohgaki.net