Re: Request for code-check
| From: | John Bafford | Date: | Thu, 10 Aug 2000 11:17:16 +0000 |
| Subject: | Re: Request for code-check | ||
| References: | 1 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-28412@lists.php.net to get a copy of this message | ||
Since you're trying to depricate force-sending an argument as reference, then what's the best way to go about sending a variable that has a default value by reference.
For example, I have the function
function DoSomething($o, $properties = 0);
And I want to be able to call it both without the last argument, and like this:
$prop = array( ... );
while(...) {
DoSomething($o, &$prop);
}
The idea being that DoSomething() is going to be executed many times with the same property set, so it doesn't make sense to have to make many copies of the array since it's not going to change. So I pass it in by reference, since I can't make the function take it by reference.
I tried, and it doesn't like it when I do this:
function DoSomething($o, &$properties = 0);
And although I _could_ "pass" the property set in as a global variable, that's just an abuse of globals and isn't a nice solution.
So, what's the best way to do this? File a bug report so that we can assign default parameters to variables passed by reference?
Thanks,
-John
I don't really have time to look at the whole thing but one thing caught my eye. You should change the function definition to force the pticket argument to be sent by reference because we are trying to deprecate the fact that the user sends with an &$foo as it is better if the pass-by-reference is defined in the function decleration. For example: PHP_FE(getimagesize,second_args_force_ref) Notice the second parameter.--- John Bafford dshadow@zort.net http://www.dshadow.com/