note 13171 deleted from language.references.unset by cece
| From: | cece@php.net | Date: | Mon, 18 Aug 2003 11:12:44 +0000 |
| Subject: | note 13171 deleted from language.references.unset by cece | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-54578@lists.php.net to get a copy of this message | ||
Note Submitter: aulbach@unter.franken.de
----
Ok, meanwhile, I understand how PHP4 is working with values, variables and references. I think
it's a good thing. My problem was in my eyes, that I'm a PHP-user from the first
beginnings, habit of "A VALUE IS A VALUE IS A VALUE" and unset() deletes the VALUE (how it
was promised in the documentation (which is wrong - I added a note there). Indeed unset deletes the
REFERENCE.
In my opinion there are some functions missing in PHP (ok, I know, that this should not be written
here, but havn't time to diskuss it in the developer list):
- is_referenced() - returns true, if the VALUE has more than one reference
- references() - an array of all referenced variables, exept the current.
false, if it has no other references
- references_all() - Returns all references, including the parameter. Does it make sense to return
also the current reference?
- unset_value() - unsetes all references to the VALUE of a variable, with this you can be sure, that
storage of this value is cleaned up. This is not the same as setting it to the value NULL, where the
references will survive. A gimmick to be consequent unset_value(&$var) should be the same as
unset($var) and delete the REFERENCE. Another good name would be simply clean() or purge().
All in all I hope this notes will help other users to understand, that there are not obvious but
very deep design changes from PHP3->PHP4 here and to keep care on them.