Re: Re: Problem with passing function return values by reference

From: Date: Fri, 17 Nov 2000 16:34:53 +0000
Subject: Re: Re: Problem with passing function return values by reference
References: 1  Groups: php.dev 
Request: Send a blank email to php-dev+get-38433@lists.php.net to get a copy of this message
CH>> ... then currently you'll get an error (because PEAR::isError() takes a CH>> reference, presumably to avoid copying objects unnecessarily). There are two Actually, AFAIK, it's exactly the reverse - it would always bring unnecessary copied when passing by reference. The reason is simple, let's do: $a = new foo(); $b = $a Here no actual copy happens still. But, if you pass $a or $b by reference, it might be modified, but the other one should remain unchanged, so copies are separated on function call. If it wan't passed by reference, no copy would happen unless function actually modifies the variable. So, using "reference" to avoid copies is totally wrong. Generally, it's bad to try to outsmart the engine - it's smart enough by itself. -- Stanislav Malyshev, Zend Products Engineer stas@zend.com http://www.zend.com/ +972-3-6139665 ext.106

« previous php.dev (#38433) next »