Re: Re: #20993 [Ver]:Elementvaluechangeswithoutasking
| From: | Melvyn Sopacua | Date: | Sat, 21 Dec 2002 18:13:36 +0000 |
| Subject: | Re: Re: #20993 [Ver]:Elementvaluechangeswithoutasking | ||
| References: | 1 2 3 4 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-92754@lists.php.net to get a copy of this message | ||
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? 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. 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.
Andi At 05:24 PM 12/21/2002 +0100, Melvyn Sopacua wrote:With kind regards, Melvyn Sopacua <?php include("not_reflecting_employers_views.txt"); ?>At 17:16 18-12-2002, Moriyoshi Koizumi wrote: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?Melvyn Sopacua <msopacua@php.net> 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 currentruntime inthe worst case. Seems no way, but I suppose it also sounds a reasonable penalty of using references.-- PHP Development Mailing List <http://www.php.net/> To unsubscribe, visit: http://www.php.net/unsub.phpThen 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