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.

> 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.

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.

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.

> boe

leo

Reply via email to