note 112285 added to language.oop5.references
| From: | cesoid at gmail dot com | Date: | Mon, 27 May 2013 16:45:11 +0000 |
| Subject: | note 112285 added to language.oop5.references | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-194971@lists.php.net to get a copy of this message | ||
Comparing an alias to a pointer is like comparing a spoken word to the neurochemistry of the
speaker. You know that the speaker can use two different words to refer to the same thing, but
what's going on in their brain to make this work is something you don't want to have to
think about every time they speak. (If you're programming in assembly or, less so, in C++,
you're out of luck there.)
Likewise, PHP *the language* and a given php interpretor are not the same thing, and this post and
most of these comments leave that out in the explanation. An alias/reference is a part of the
language, a pointer is a part of how the computer makes the reference work. You often have little
guarantee that an interpreter will continue working the same way internally.
From a functional point of view the internals of the interpreter *do* matter for optimization, but
*don't* matter in terms of the end result of the program. A higher level programming language
such as PHP is supposed to try to hide such details from the programmer so that they can write
clearer, more manageable code, and do it quickly.
Unfortunately, years ago, using pass-by-reference a lot actually was very useful in terms of
optimizing. Fortunately, that ended years ago, so now we no longer need to perform a reference
assignment and hope that we remember not to change one variable when the other one is supposed to
stay the same. By the time you read this the php that is sending these words to you may be running
on a server that uses some kind of new exotic technology for which the word "pointer" no
longer accurately describes anything, because the server stores both the program state and
instructions intermingled in non-sequential atoms bonded into molecules which work by randomly
bouncing off each other at high speeds, thereby exchanging atoms and crossbreeding their
instructions and information in such a way as to, in aggregate, successfully run php 5 code. But the
code itself will still have references that work the same way they did before, and you will
therefore not have to think about whether the machine I just described makes any sense at all.
----
Server IP: 69.147.83.199
Probable Submitter: 71.192.26.224
----
Manual Page -- http://php.net/manual/en/language.oop5.references.php
Edit -- https://master.php.net/note/edit/112285
Del: integrated -- https://master.php.net/note/delete/112285/integrated
Del: useless -- https://master.php.net/note/delete/112285/useless
Del: bad code -- https://master.php.net/note/delete/112285/bad+code
Del: spam -- https://master.php.net/note/delete/112285/spam
Del: non-english -- https://master.php.net/note/delete/112285/non-english
Del: in docs -- https://master.php.net/note/delete/112285/in+docs
Del: other reasons-- https://master.php.net/note/delete/112285
Reject -- https://master.php.net/note/reject/112285
Search -- https://master.php.net/manage/user-notes.php