The future of call time pass-as-reference
| From: | Frank | Date: | Thu, 16 May 2002 00:13:34 +0000 |
| Subject: | The future of call time pass-as-reference | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-97841@lists.php.net to get a copy of this message | ||
After installing PHP 4.2.0 I got the following error-message under a run:
"Warning: Call-time pass-by-reference has been deprecated - argument passed by value; If you would like to pass it by reference, modify the declaration of [runtime function name](). If you would like to enable call-time pass-by-reference, you can set allow_call_time_pass_reference to true in your INI file. However, future versions may not support this any longer. "
This is actually big news as parameter passing is a fundamental issue.
Traditionally
function foo($v) called as
foo(&$myvar)
was regarded as safer coding than
function foo(&$v) called as
foo($myvar)
as in the first case the user would automatically be aware that $myvar could be changed by the function, in the second not.
Worse is that in some functions it makes fine sense for the user to have a choice. These functions will be very hard to rewrite as the user will be forced to references in all cases.
Finally default parameters are not supported for reference-parameters in the function header.
Anyway - it seems that I have to choose between either starting to rewrite quite a lot of code right away or risk being forced to rewrite more later if I use the quick fix with setting allow_call_time_pass_reference to true.
Any thoughts?
Frank