Re: [PHP4BETA] return references branch merged into the main repository

From: Date: Wed, 15 Dec 1999 22:17:11 +0000
Subject: Re: [PHP4BETA] return references branch merged into the main repository
References: 1 2 3 4 5 6 7  Groups: php.version4 
Request: Send a blank email to php-version4+get-7980@lists.php.net to get a copy of this message
On Thu, 16 Dec 1999, Zeev Suraski wrote: > If you use no special notation, foo() is a standalone expression, not > different from $var. When you assign this expression to another variable, > if you assign it using the standard assignment notation, it'll create a > copy of whatever that expression was (foo() could have returned a > reference, and $var could have been a reference, but when you assign them > to some variable, that variable, no matter what, will not be a reference to > them but a copy of them). > > To assign a reference, you must use the special assign-reference > notation. When assigning a variable, the notation does the job of > converting the variable to a reference if necessary. When assigning a > function return value, you must first have a function that returns a > reference (because we don't want users to take references from functions > that aren't designed for that), and then still, say that you want to > actually take a reference from that reference, and not create a copy of > it. It's just a matter of consistency. Ok, I'm just saying it's going to be real easy to forget that & if you know function returns a reference. -Andrei The Heineken Uncertainty Principle: You can never be sure how many beers you had last night.

« previous php.version4 (#7980) next »