Kaz Kylheku <firstname.lastname@example.org> wrote:
| Trastabuga <lisper...@gmail.com> wrote:
| > How can I do a deep copy of the list so it creates a completely new
| > instance of that branch?
| You could perform a COPY-TREE first, followed by a recursive walk of
| the newly consed tree structure, in which you replace all mutable
| atoms by copies.
| This is difficult to do in general, because there is no unified
| operation for copying any atom. You could write a generic copy
| function and specialize it to the objects you care about in your
But then next week somebody comes up with a new atom that his generic
COPY-ATOM doesn't know about, and he has to invent a new specialization
for it... which is *NOT* trivial, in general. Kent's classic article
on copying & equality goes into some of the reasons why not:
but the example that does it for me is the case of objects with
internal constraints between their components, e.g., a queue header
which contains a tail pointer that points to the end of the queue, or
a bidirectional queue or doubly-linked list type. Or a general graph
with loops? All of these create problems for a COPY-ATOM operation.
Or what about objects with semantics that are supposed to represent
external objects? Is it fraud when one does (COPY-ATOM BANK-ACCOUNT)?
And if one does (COPY-ATOM AIRLINE-SEAT-RESERVATION), who loses the
resulting game of musical chairs?
Rob Warnock <email@example.com>
627 26th Avenue <URL:http://rpw3.org/>
San Mateo, CA 94403 (650)572-2607