Re: References
| From: | Kristian Köhntopp | Date: | Mon, 17 Jul 2000 08:42:20 +0000 |
| Subject: | Re: References | ||
| References: | 1 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-24698@lists.php.net to get a copy of this message | ||
Stanislav Malyshev wrote:
> KK>> IP source and so on. You'd do this by building arrays of
> KK>> references to the actual measurements, ordered by the
> KK>> characteristic you need. You'd use measurements in order
>
> For this, you don't really need references. You may use them, but you
> might use indexed hashes as well, or just copy (mosy copies in PHP aren't
> really a copy unless you write the data - PHP likes to copy-on-write).
You cannot use copies, or you run in the usual paradoxa. Effectively,
this is a normalization process, as in database schema normalization,
but done with data structures in memory. A Reference to a data
structure is what a foreign key into a table.
And in order to save such a system of data structures referencing
each other to disk, and keep their order, you have to handle references
properly (i.e. keep them across the serialization) or they are
second class data objects. If this is the case, it should be a
documented limitation and personally, I think that such a limitation
is pretty severe, as it hinders you to build properly engineered
data structures in memory.
You could fake all this manually the BASIC way, by using array
indices and manual nesting of array lookups, but references were
invented in the first place to make such painful code obsolete.
> KK>> to avoid duplication of the data, and in order to avoid
> KK>> update anomalies.
>
> If you are changing the data, hashes would be better solution. References
> have many unexpected side effects and it's better not to use it unless you
> have very clean understanding of how they work, and even then...
Actually, ONLY and ALWAYS using references and creating copies only
on explicit request is what is the expected behaviour for many
people.
Kristian
--
Kristian Köhntopp, NetUSE AG Siemenswall, D-24107 Kiel
Tel: +49 431 386 436 00, Fax: +49 431 386 435 99
Using PHP3? See our web development library at http://phplib.netuse.de/