Rand Changes

From: Date: Sun, 02 Sep 2001 23:34:27 +0000
Subject: Rand Changes
References: 1  Groups: php.dev 
Request: Send a blank email to php-dev+get-64924@lists.php.net to get a copy of this message
Howdy, I have a few problems with the latest random number related commits, most importantly being the quality of the underlying code, rather than some of the changes it implements (which are also un-necessary, imho, if it ain't broke -- don't "fix" it). 1) On a style note, the code makes poor use of macro's, pim_srand_common is a good example of a macro gone wrong.. 2) It's un-optimized, and the code does not follow a logical structure, one indication of this is the PHP_FUNCTION_RAND() and PHP_RAND_RANGE(), which does too much for a macro in this case (and comments like that really don't belong in a macro). Also, folks, don't use "register" on a variable that will be accessed twice. 3) I don't think the extra level of abstraction is warranted in this case -- it slows things down, it doesn't speed them up, and there is really no great improvement from an API perspective to doing this. 4) What was sooooooo wrong about the way we were doing things? Even though we don't have a voting system, I'm a strong -1 on this patch. :))) Instead -- changes that I think would be a good idea (and I'll implement these if you don't want to Jeroen) are: a) Making the seed argument optional to [mt_]srand(), and use the most random seed possible if no seed is specified, this is a good way to help out people. b) Update to the php4 api, and remove some of the redundant logic in rand.c pre-patch (well redundant from a PHP4 perspective). -Sterling

« previous php.dev (#64924) next »