Re: serializing references, almost without modifications

From: Date: Fri, 21 Jul 2000 08:45:27 +0000
Subject: Re: serializing references, almost without modifications
References: 1 2  Groups: php.dev 
Request: Send a blank email to php-dev+get-25326@lists.php.net to get a copy of this message
Andi Gutmans wrote: > But just to give my 2 cents to this discussion I must say that Stas is > pretty right. If you want to serialize references you will need to save > some lookup table during serialization and make sure that each serialized > zval is given an id. When you encounter a reference you have already > serialized just serialize with the original id. You'd need that hash even if Zend "symlinked" referenced instead of "hardlinking" them, in order to detect circular references of the kind "$a = &$b; $b = &$a;". In a system with symlinked references you must remember what you have already seen and must not serialize a value twice in a single run. In a system with hardlinked references this cannot happen, because all pointers are from the symbol table into the value pool, only that some values are referenced multiple times from the symbol table. In such a system you need the "beenthere" hash to correctly detect values you have already seen as Andi described. The symlinked system can serialize transitively, that is, it can follow references and detect values referenced by the original value. In a hardlinked system, there is no such ability. That's about the only difference. 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/

« previous php.dev (#25326) next »