At 07:13 PM 12/21/2002 +0100, Melvyn Sopacua wrote:
At 18:24 21-12-2002, Andi Gutmans wrote:
Yes I object. Think of references as a "symbolic link" to the same place.
Now you have such a reference in an array which you assign to an
additional variable. Now two variables contain copies of an array but
somewhere inside you have two copies of the symbolic link. Changing one
will change the other. In many ways it makes sense, and even in cases
where it's a bit weird and where it seems wrong, I think we should live
with it because I don't like having to check the whole array each time.
If you have deeply nested arrays it's really slow and doesn't make that
much sense.
Ok - so there's no way to detect this at the lexer level?
Nope.
I get the symlink anology, but IMO it doesn't apply here. A copy of the
array is passed to the function - not a reference.
Yeah but one of those values inside the array is a reference. In both the
original and the copy of the array it's the same reference.
If you wanna keep the anology, then this resembles symlinking a file,
inside a directory and changing a *copy* of the directory, changes the
original directory.
So - IF it can't be warned about - then we need a big fat warning in the docs.
Definitely I think a big warning is in place.
Andi
Andi
At 05:24 PM 12/21/2002 +0100, Melvyn Sopacua wrote:
At 17:16 18-12-2002, Moriyoshi Koizumi wrote:
Melvyn Sopacua <[EMAIL PROTECTED]> wrote:
--snip
> > > OK so that's a deep copy. As much as I understand the motivation
I don't
> > > think this should be done. It'll slow down lots of things in
PHP. I think
> > > this should be solved by documentation.
> >
> >Yes, according to my trivial benchmark, my patch puts a considerable
> >weight on the ZendEngine, to run twice as slowly as the current
runtime in
> >the worst case. Seems no way, but I suppose it also sounds a reasonable
> >penalty of using references.
>
> Actually - the natural 'feeling' with references is speed increases
- not
> slowdowns,
> since one expects a 'pointer', rather than a copy.
>
> Is there a way to warn when such a refstatement is detected, without
> causing slowdowns?
Then try the new patch. It prints out notices in such cases.
Attached is a slightly revised version against PHP_4_3 branch - just an
'english'
fix.
If there are no objections, can somebody commit it?
I'll fix the test accordingly.
With kind regards,
Melvyn Sopacua
<?php include("not_reflecting_employers_views.txt"); ?>
--
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php
--
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php
With kind regards,
Melvyn Sopacua
<?php include("not_reflecting_employers_views.txt"); ?>
--
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php