Re: serializing references, almost without modifications

From: Date: Wed, 19 Jul 2000 14:10:13 +0000
Subject: Re: serializing references, almost without modifications
References: 1  Groups: php.dev 
Request: Send a blank email to php-dev+get-25104@lists.php.net to get a copy of this message
WdL>> WdL>> $a = 1; WdL>> $b = &$a; WdL>> $c = &b; WdL>> WdL>> Shouldn't be $c be a reference direct to $a then and so not be nested? Again. $c is not reference to $a. What do you have is: First you have symbol table which has "a" entry, pointing to zval which contains 1. Second, you have two entries, "a" and "b", which point to zval with is_ref = 1 and refcount 2. Third, you have three entries, "a", "b" and "c", which all point to the same zval, now having refcount 3. Now, given that zval, you can't discover it's names unless you sweep symbol table. WdL>> >Are you really sure that╢s not an option (at least a workaround until/if WdL>> >caught later)? Otherwise there╢s really no way I could think of without WdL>> >introducing a reference hash or similar. The only way I see after thinking a bit on this is sort of LZW algorithm on variables. While serializing, keep serialized zval's in some list/hash, and if you see some zval twice, with is_ref set, you mark it as "referenced" in serialized data, pointing out which var it refers somehow (maybe just with running number). I'm not sure it is going to work in 100% of cases, needs much thinking about that. -- Stanislav Malyshev stas@zend.com +972-3-6139665

« previous php.dev (#25104) next »