From ... From: Erik Naggum Subject: Re: copy construction in CLOS Date: 1999/02/13 Message-ID: <3127867690633121@naggum.no>#1/1 X-Deja-AN: 443862619 References: <36c24063.20444473@news-server.austin.rr.com> mail-copies-to: never Organization: Naggum Software; +47 8800 8879; http://www.naggum.no Newsgroups: comp.lang.lisp * dyoder@tazent.com (Daniel J. Yoder) | Another newbie question. I am a little confused by the lack of any | explicit notion in CLOS for copying an object. there is no such thing as a copy of an object. let me clarify before you object. let's define a copy of an original object to be an object equal to the original in all respects save that if you alter the copy, you do not also alter the original. that seems to imply deep copy, but I think it means shallow copy. now, since "copy" is defined in terms of the possible alterations, it should be intuitively evident that there is a _purpose_ to a copy that needs to be communicated. e.g., when I want a copy of a _list_, I want a fresh cdr chain that I can modify, but I do _not_ thereby want copies of all the elements of the list. Common Lisp offers COPY-LIST to copy the cdr chain, COPY-ALIST to copy the cdr chain and any cons cells that are members of the list, and COPY-TREE to copy all cons cells. this is pretty specific, don't you think? try to communicate this to a generic copy for lists. and, since "copy" is defined in terms of "equal", which does not include the object identity at some level or another, and possibly any number of other properties, all the problems of a generic EQUAL apply with full force. you'll note that there is no EQUAL for class instances, either. I yield the floor to Kent Pitman on EQUAL. :) #:Erik -- Y2K conversion simplified: Januark, Februark, March, April, Mak, June, Julk, August, September, October, November, December.