Re: Request for code-check

From: Date: Thu, 10 Aug 2000 15:13:50 +0000
Subject: Re: Request for code-check
References: 1 2  Groups: php.dev 
Request: Send a blank email to php-dev+get-28440@lists.php.net to get a copy of this message
Default arguments to by-ref arguments doesn't make sense, which is why it's not implemented. The function expects a by-ref argument, and a default value would be a reference to nothing. It might make sense to let by-ref arguments have NULL default values, or in other words, allow the function to silently ignore a situation where the argument isn't sent. We need to think about it. Zeev At 14:17 10/08/2000, John Bafford wrote:
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/ -- PHP Development Mailing List <http://www.php.net/> To unsubscribe, e-mail: php-dev-unsubscribe@lists.php.net For additional commands, e-mail: php-dev-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net
-- Zeev Suraski <zeev@zend.com> http://www.zend.com/

« previous php.dev (#28440) next »