One important thing to keep in mind is that there is no global uniform implementation of 'clone': the clone op just calls the clone vtable function, and each PMC is free to implement it however it chooses. (This is a good thing, different languages have different semantics for cloning.)

Given that the primary purpose of core PMCs like hash and array is to provide simple default behaviors for various language implementations, I'm okay with making them shallow clones rather than deep clones (after a suitable deprecation cycle, and a chance for current HLL devs to let us know if this is likely to cause them problems).

As chromatic pointed out in the ticket, there's a substantial advantage to (eventually) solving the problem of unique traversals once for all potential uses, including deep cloning, freezing, marking RO or shared variables, some kinds of iterators, and potentially GC marking.

A simple registry is a good idea, but it should be more general than a "clone registry". A better approach would be a "seen registry" marking nodes that have been visited in a particular traversal (whatever is being done by that traversal). Storing the registry in interp is unsafe, because you may have multiple traversals happening simultaneously. (I'm not even talking about concurrency, where global state is the plague. Simple sequential code may traverse part-way through a data structure, then call some other code that traverses through some other data structure.) Storing it the PMC struct of the item being traversed is better, but still unsafe because you may have multiple processes iterating over the same PMC at the same time. What you really want is data storage for the registry that's unique to each traversal.

Allison
_______________________________________________
http://lists.parrot.org/mailman/listinfo/parrot-dev

Reply via email to