|
Posted by Summercool on 09/28/07 06:41
so many places, including the book PHP in a Nutshell, p. 80, it says:
$a =& $b # set $a to reference $b
if $a reference $b, then while you can say $b =1, you can't really
say $a = 1. you need to say *($a) = 1 as in C or C++. Referencing
must be coupled with dereferencing, and PHP is not doing the
dereferencing, so why is it call referencing in the first place?
(don't tell me PHP automatically dereference... as it will be really
weird).
and i think in the PHP group, people say "reference" to mean "alias".
So my questions are
1) If it is by reference, why don't you need to dereference it as
mentioned above?
2) There are actually two "reference" methods (as in my previous post
topic). One is $obj1 = $obj2, and it works the same as in Java,
Python, and Ruby (maybe in Perl too?). The other behavior is the $a
=& $b and it is different, and why is it still called "reference"?
Why having two different behaviors use the same name which is
"reference"? Why not call $a =& $b aliasing, and call $obj1 = $obj2
copying the reference? ($obj2 reference an object, and so copy this
reference to $obj2)
In a way, if C, C++, Java, Python, Ruby, all use the word reference to
mean $obj1 = $obj2, if PHP wants to be different and call "aliase" as
"reference", and different from the rest of the world, I can respect
that. But the thing is, why call it reference and then have the other
behavior $obj1 = $obj2 which is different, and AGAIN call it reference?
Navigation:
[Reply to this message]
|