HOWTO: &new notation OR Copy-by-Value

From: Date: Fri, 23 May 2003 10:25:14 +0000
Subject: HOWTO: &new notation OR Copy-by-Value
Groups: php.pear.general 
Request: Send a blank email to pear-general+get-5565@lists.php.net to get a copy of this message
Hi, I just wanted to make sure that I do understand right: It looks like that many programmers use the wrong notation for objects created by "new", meaning stg like this: pointer = new Object(); We actually create an object and COPY it into pointer. The proper way to do that would be rather pointer = & new Object(); This makes sure we work on the newly created object rather than on a copy of that. Saves memory, prevents problems concerning data integrity and so on and so forth. Though you find the first assignment rather frequently in actually used code, also in PEAR. So, what? Is it the policy to leave the situation as is and don't change anything, and just wait for PHP5 which would by definition only assign the reference? I see that inserting alot of ampersands into existing code which renders useless with the new PHP5 is quite too much work for nothing. Right? Can we settle on that? Strange though! Or not? Marko

« previous php.pear.general (#5565) next »