note 76129 added to language.references.pass
| From: | riseofthethorax at gmail dot com | Date: | Sun, 01 Jul 2007 22:44:31 +0000 |
| Subject: | note 76129 added to language.references.pass | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-128147@lists.php.net to get a copy of this message | ||
Okay got it.. Why can't you guys just weed this out in the preprocessor? It's nothing more
than a syntactical difference..
function foo(&$a) {
$a = ($a++) * 6;
}
$x = 10;
foo($x);
print $x ; // 66
versus
foo(&$x);
which probably gets interpretted as pass a reference to x,
then once in foo, a reference is made to a reference of x..
I suppose this would be a memory leak because $a is
now a reference to $x that was declared when calling the function, is not being used by anyone..
I suppose it is like this..
we call foo(&$x);
A reference (I'll call it $*) is created that links to $x.
Inside foo, $a is assigned a reference to $*, which is $x.
$x is modified with $a is modified..
Coming out of foo.. $a is destroyed..
reference $* still exists because it was created outside of foo..
But there is no way of referring to it because it has no name..
Is this the reason, is this why call-time pass-by-reference was deprecated??
I don't see why it was just weeded out by the preprocessor.. Nobody would make use of this
artifact..
However, I need pass by reference, there is no way I can get stuff done without it..
----
Server IP: 64.71.164.2
Probable Submitter: 69.241.171.211
----
Manual Page -- http://www.php.net/manual/en/language.references.pass.php
Edit -- https://master.php.net/note/edit/76129
Del: integrated -- https://master.php.net/note/delete/76129/integrated
Del: useless -- https://master.php.net/note/delete/76129/useless
Del: bad code -- https://master.php.net/note/delete/76129/bad+code
Del: spam -- https://master.php.net/note/delete/76129/spam
Del: non-english -- https://master.php.net/note/delete/76129/non-english
Del: in docs -- https://master.php.net/note/delete/76129/in+docs
Del: other reasons-- https://master.php.net/note/delete/76129
Reject -- https://master.php.net/note/reject/76129
Search -- https://master.php.net/manage/user-notes.php