Robert Cummings wrote:

> On Wed, 2006-01-18 at 15:36, Mark wrote:
>>
>> [-- CLIPPED --]
>>
>> Here's a point of debate, should this sort of behavior be allowed? If it
>> is allowable, how does one support it in any sort of serialized
>> methodology? I have a few ideas but none very pretty. I'm pretty sure it
>> causes problems in regular PHP as these sorts of pages sometimes have
>> problems anyway.
> 
> Yes it should be allowed, yes you can serialize it. Look at PHP's
> serializer. You'll notice they track recursive structures and properly
> unserialize them. One way to do it is to unroll objects into a single
> lookup. When you FIRST encounter an object assign it a unique ID (make
> it a property on the object that is unlikely to collide with any other),

This was that "but nove very pretty" options I was thinking about.

> add the object to the lookup with the UID as the key and continue
> serializing, the next time you encounter the object, you know you're
> recursing and so in your serializer you have a special marker that
> indicates the current object points to an existing serialized object
> with the given UID. Then you move onto the next item. Your unserializer
> will then be able to traverse the serialized data and as it comes across
> objects it can create the same lookup and when it hits the recurse
> marker it will know to create a reference to the original.
> 
> The implementation is slightly more difficult than what I've just
> described, but simple enough :)

It's truly ugly, don't you think?

> 
> HTH,
> Rob.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to