Dan Sugalski <[EMAIL PROTECTED]> wrote: > On Fri, 29 Aug 2003, Leopold Toetsch wrote:
>> I think, we need a general solution for freeze, dump and clone. As shown >> the latter is broken. That would be IMHO an iterator interface with a >> callback function taking and returning a void*. > Right, what I want is for the system freeze/thaw routines to have a > standard way to encode a variety of core types (ints, floats, strings), > lists, and hashes, as well as a way to handle self-referential, circular, > and shared data in the dumped PMC data. It's the only way to safely do > this, since we can't count on all the different PMC classes to handle > dumping arrays of arrays of references to the same end PMC properly. Which > we have to if we want this to work right. >> The freeze(), dump() and clone() would be vtables which are called by >> the iterator. So this functions hould have the same signature. > No iterator. When you call freeze on a PMC, that PMC is responsible for > any sort of iteration that may have to be done. (Though there is the issue > of blowing stack, which we'll have to address) Aren't you saying the opposite of above here? I want to be able to traverse from a given start point (being it the own interpreter or some PMC) as deeply down as there is something. You did say, that we don't recursively mark() because of recursion depth. clone(), dump(), freeze() all have these same issues (plus self-referntial structures). That's way I'm speaking of an iterator. An array can't clone() itself safely. It can clone() the SELF pmc and then put array items on a TODO list, which then get cloned by the framework. Its like interpreter->mark_ptr holding a TODO list of items still to mark, which can put other items onto this list too. So I'm speaking of a framework, which calls a vtable->traverse() method that calls vtable methods (freeze, clone, dump, or whatever) on SELF and then puts aggregate items (if any) on a TODO list. This functionality is IMHO that of an iterator. This does address stack blowing and self-referential structures. The TODO list can be avoided for plain items, samething as we do in pobject_lives(). > Dan leo