Venkat wrote:
> is there any facility to clone objects in lisp?
> I want to create a new copy of a (value or list or instance)
> how can we do
If your thinking about Java's clone funcionality, you should know that
a generic clone function is a bad idea. Though perhaps too advanced
for a Lisp newbie, Kent Pitman's article
http://www.nhplace.com/kent/PS/EQUAL.html explains this very well.
Sebastian
"Freedom is the freedom to say (= (+ 2 2) 4). If that is granted, all
else follows."
On 22 Oct 2003 08:18:02 -0700
········@yahoo.com (Sebastian Stern) wrote:
> Sebastian
> "Freedom is the freedom to say (= (+ 2 2) 4). If that is granted, all
> else follows."
Heh, I like the quote, however, I don't think Orwell used Lisp. :)
Jason Creighton
"Jason Creighton" wrote:
> > Sebastian
> > "Freedom is the freedom to say (= (+ 2 2) 4). If that is granted, all
> > else follows."
>
> Heh, I like the quote, however, I don't think Orwell used Lisp. :)
Thanks. If you like my quote, you will probably also like "Making an analogy
in the context of George Orwell's 1984: As English is to NewSpeak, so is
Lisp to C" (snipped from the Chris-Perkins' Road To Lisp).
Sebastian
"Freedom is the freedom to say (= (+ 2 2) 4). If that is granted, all
else follows."
············@yahoo.com (Venkat) writes:
> is there any facility to clone objects in lisp?
yes, several. Look up all the functions beginning with COPY- in
the spec. COPY-SEQ might be the one you want to look at first, since
it is useful for strings, lists and arrays.
--
(espen)
Venkat wrote:
> is there any facility to clone objects in lisp?
> I want to create a new copy of a (value or list or instance)
> how can we do
There is copy-list, for one.
(defstruct xxx) silently constructs make-xxx and copy-xxx.
I doubt your implementation has a copy-instance for CLOS. You can write
one, tho, by iterating over the slot names (returned by some
implementation-dependent MOP call such as class-slots) and using
SLOT-VALUE to get and set slots.
kenny
--
http://tilton-technology.com
What?! You are a newbie and you haven't answered my:
http://alu.cliki.net/The%20Road%20to%20Lisp%20Survey
············@yahoo.com (Venkat) writes:
> is there any facility to clone objects in lisp?
Not a generally useful one, mostly because there is no generally
useful definition of "cloning".
> I want to create a new copy of a (value or list or instance)
> how can we do
There's COPY-LIST, COPY-TREE, COPY-SEQ, COPY-STRUCTURE etc. For
instances, you'll have to roll your own, AFAIK.