making copies of class instances

From: Brian Denheyer <briand_at_soggy.com>
Date: Mon, 6 Jan 1997 19:49:33 -0800 (PST)

Given that I have class definitions :

(define-class <foo> ()
 (slot1 etc...))
 
(define-class <foo-bar> ()
 (foo-slot :init-keyword :foo-slot)
 (other slots...))
 
I can then initialize an instance of foo-bar with an existing foo object :

e.g.
(define x1 (make <foo>))

(define make-foo-bar
 (lambda (foo-obj args)
  (make <foo-bar> :foo-slot a-foo-obj)))

(make-foo-bar x1 args)

It appears that "foo-slot" now holds a _reference_ to , i.e. not a copy of,
the intializing object x1. So if I do this with multiple foo-bar objects and
then change the value of the foo-slot object the change will be reflected in
the object used to intialize the slot.

This is actually what I want...but, if I didn't want this to happen how
would I set up the foo-bar object with a local copy of foo ?

I think that I am asking if there is a "neat" way of doing
a deep-copy of an instance of a class.


-- 
Brian Denheyer
briand_at_northwest.com
-----------------------------------------------------
"We need skeptical thinking about everything - social organization,
economics, religion, science, politics.  We need the ability to be equipeed
with a baloney detection kit.  And that ought to be the job of schools and
the media, but in my view they both do a rotten job, in part because those
in power aren't interested in having widely available baloney-detection
kits." 
					-- Carl Sagan 
Received on Tue Jan 07 1997 - 04:48:09 CET

This archive was generated by hypermail 2.3.0 : Mon Jul 21 2014 - 19:38:59 CEST