[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Copying representation parents



Here's an idea: Create a child of 'traits clonable' (call it 'traits
copyable', say) which automatically copies all parents if they include
a special slot, say '_ representationParent' (similar to the
'_ thisObjectPrints' slot).  You would use a mirror on the parent to
find out if there is a 'representationParent' slot.  If there is one,
you would recursively copy the parent.  This allows "grand-parents" to
be copied as well.  Note that the parent would generally not inherit
from 'traits copyable', so the recursive copy method would have to
recurse on an argument rather than on the receiver.

This idea may also be extended to copying children.  The problem is
that you can't necessarily add a slot to the children.  For example,
how would you add a slot to a list?  You would have to use a sibling
slot with a related name.  At a certain point, it becomes easier to
just write your own copy method!


- Danny Epstein
  dje@scs.carleton.ca