Leopold Toetsch <[EMAIL PROTECTED]> writes: > Juergen Boemmels <[EMAIL PROTECTED]> wrote: > > Leopold Toetsch <[EMAIL PROTECTED]> writes: > > >> STRING* dump(INTERP, SELF, STRING *, INTVAL flags); > > > what is the STRING * parameter good for. I assume lineheaders. > > The place, where to append SELF.dump. Appending doesn't consume a new > header for each piece.
Ah, ok. How do you want to solve indentation in multiline dumps? With an additional indent parameter? > > Use the lower bits for nesting depth. This way you can use > > n = flags & 0xff to obtain the nesting depth, and still define > > the flags which can be passed to the passed to dump of the childs: > > dump (..., (flags & ~0xff) | n-1); > > That would restrict the nesting depth. 2 more shifts don't harm, > dump()ing will be slow enough. Ok, then use a mask of 0xffff. Or even 0xffffff (I don't want to see a dump of depth 4 million on my screen). I wanted to keep the opportunity to pass the other flags like "multiline" or "name only" down to the childs. > BTW what about self-referential structures (same problem as with clone): > > $ cat rclone.pasm > new P0, .PerlArray > new P1, .PerlInt > push P0, P1 > push P0, P0 > clone P2, P0 > end > > $ ulimit -m 5000 # don't forget, if you havn't any > $ parrot rclone.pasm > Segmentation fault (core dumped) > > I'm thinking of dump to be: > - if (flag) return > - set a flag on SELF > - dump children > - reset flag > > But this doesn't help against very deeply nested structures. An > alternative would be to have a general iterator with a todo-list like the > current DOD mark_ptr. We could use a generalization of the mark-scheme > by passing a function argument for DOD too with some? impact on DOD > performance. A general nesting iterator would be a good idea. It might be useful in quite a few places: DOD, destruction ordering, dumping, serialisation, cloning. But DOD is the most timing-critical: It's called often and has to visit all active objects, whereas the others only visit the affected objects (the ones which gets destructed, dumped, serialized, cloned). > When we want to use this for serialization too, we need some means to > refer to an already visited PMC, passing an optional hash would do it > IMHO. When using callbacks they often have a void* params. The interpretation of this *params is job of the callback. boe -- Juergen Boemmels [EMAIL PROTECTED] Fachbereich Physik Tel: ++49-(0)631-205-2817 Universitaet Kaiserslautern Fax: ++49-(0)631-205-3906 PGP Key fingerprint = 9F 56 54 3D 45 C1 32 6F 23 F6 C7 2F 85 93 DD 47