Re: [PHP4BETA] Re: convert_to_string_ex is not the solution.
| From: | Zeev Suraski | Date: | Fri, 17 Sep 1999 13:41:19 +0000 |
| Subject: | Re: [PHP4BETA] Re: convert_to_string_ex is not the solution. | ||
| References: | 1 | Groups: | php.version4 |
| Request: | Send a blank email to php-version4+get-4575@lists.php.net to get a copy of this message | ||
On Fri, 17 Sep 1999, Thies C. Arntzen wrote:
> zeev,
>
> i think i do agree (mostly;-)
>
> but how can i write a internal function that does not change the
> supplied parameters? if the scripter passes parameters via reference i
> should have a way to eg find out the string value for it without
> converting the users variable into a string!
That may be true. First (at the risk of repeating myself once too many),
you must realize this isn't a getParametersEx() or a PHP 4.0 issue, but a
problem that's been around since the very first alpha of PHP 3.0.
Now, there are two ways to go about this:
1. The newly introduced convert_to_*_ex() macros deliberately avoid
separating arguments that were passed by reference (to retain the
'advertised' functionality). I could easily write macros (or add a flag
to the current macros) that causes them to separate the arguments
regardless of whether they are passed by reference or not.
2. The above solution is not comprehensive - it doesn't give you any
tools to prevent the same thing from happening with legacy non-Ex code. A
comprehensive solution would be preventing the user from passing stuff by
reference to functions that advertise that they're not willing to take
stuff by reference. I haven't looked at the variable passing code for a
few months now, but it should be doable if we decide it's really
necessary. Whether it's necessary, though, is a big question. I don't
think people send arguments by reference just for the hell of it.
We've had this behavior in PHP 3.0 for 1.5 years, and I don't recall a
single 'what the hell is going on' complaint about something of the sort
(and just about any PHP function modifies its arguments, and they all
happily take their arguments by reference if the user decides to do so).
> > .... With PHP 4.0, the performance increase from passing by
> > reference is gone (since passing any type of argument is only a matter of
> > increasing reference count), but everything else still applies.
>
> as of now the performance increase is still there unless the internal
> function uses getParametersEx().
True.
Zeev
--
-----------------------------------------------------
Zeev Suraski <zeev@zend.com> http://www.zend.com/
For a PGP public key, finger bourbon@netvision.net.il