Re: Fwd: Re: [PHP-PEAR] PEAR::isError()

From: Date: Tue, 05 Dec 2000 09:08:32 +0000
Subject: Re: Fwd: Re: [PHP-PEAR] PEAR::isError()
References: 1 2 3  Groups: php.dev 
Request: Send a blank email to php-dev+get-40089@lists.php.net to get a copy of this message
Zeev Suraski wrote: > > At 23:01 4/12/2000, Chuck Hagenbuch wrote: > >Quoting Andi Gutmans <andi@zend.com>: > > > > > Why does it make sense to send constants by reference? > > > >It doesn't, unless you mean that the boolean value true (I capitalized it > >in a > >mistaken attempt to add clarity; sorry) is a constant. If you have a method > >which returns true on success and an error object on failure, it would be > >nice > >to be able to pass that to PEAR::isError(). However, as things stand, we can > >only do that if PEAR::isError() doesn't take parameters by reference, which > >means that we get a performance hit every time it _is_ called with an object. > > true/false behave like constants, pretty much. > I wouldn't change scripts to pass things by reference just because it's > faster, if it's not the right thing to do, and apparently, it's not the > case here... I must confess that I did not meter the lastest 4.0.4dev version but a version before (4.0.1dev or so) and I can't say that reference are faster. The opposite is true in my eyes. In PHPDoc there are many, many situations where I thought of passing by reference or using references. But I did not - not only to be PHP 3 compatible. Pass by value seems to be faster. At least with huge arrays as they get used in PHPDoc (tree structures need references...). Combined with the never ending trouble references made in the past (and as it seems in the presence) I wouldn't use references. There're only very few situations where you really need them. By the way, Dietmar Glachs told me that phpDOM got faster as he dropped the references. Ulf

« previous php.dev (#40089) next »