Subject: Re: How powerful macros are?
From: rpw3@rpw3.org (Rob Warnock)
Date: Thu, 24 Mar 2005 03:28:05 -0600
Newsgroups: comp.lang.lisp
Message-ID: <etednYDYDa-4Fd_fRVn-rQ@speakeasy.net>
Frank Buss  <fb@frank-buss.de> wrote:
+---------------
| But how to handle nested lists? I think this could fail:
| 
| (defparameter *test* (copy-seq '(1 (2 3) 4)))
| (setf (caadr *test*) 9)
+---------------

As Andras Simon noted, COPY-TREE would handle this one.
[But not your next one...]

+---------------
| I need something like a deep-copy-seq. But is it possible
| to write such a function, which can handle all literal objects,
| for example arrays? 
| (defparameter *test* (deep-copy-seq '(1 #(2 3) 4)))
+---------------

Perhaps, if you go no farther than including arrarys containing
"simple" constants, such as this example...

But this is an old and very rich topic, much-discussed in this group.
It turns out that "deep copying" is not a well-defined, or at least
not a universal, operation, any more than "deep equality" is. The
upshot is that in DEEP-COPY, "the right thing" turns out to be very
application-dependent. Look for past threads with subjects like
"multiple copies of a CLOS object?", especially the comments in those
threads by Kent Pitman, who has written what is now a short classic
on the topic -- <http://www.nhplace.com/kent/PS/EQUAL.html> -- which
despite the URL & title is about copying as well, and should help
answer your question.


-Rob

-----
Rob Warnock			<rpw3@rpw3.org>
627 26th Avenue			<URL:http://rpw3.org/>
San Mateo, CA 94403		(650)572-2607