Lisp HUG Maillist Archive

Re: copy-object

I don't understand the implementation of CLOS objects.
 They seem a lot more complicated than I would have
thought.  How are they represented at the machine
level?  Are the slots in contiguous memory?  Is the
class referenced from a pseudo-slot, so the object
will know what class it is?  What else does the object
have, making it impossible to just do a raw memory
copy of the whole object?

I would also like to know if CLOS objects start out in
a different generation of GC memory than other types
of objects.  Or is there some other reason why their
memory might take longer to allocate?

--- Nick Levine <ndl@ravenbrook.com> wrote:
> Something like:
> 
>   (defmethod copy-object ((x standard-object))
>     (let* ((class (class-of x))
> 	   (slot-definitions (class-effective-slots class))
> 	   (slot-names (mapcar 'slot-definition-name
> slot-definitions))
> 	   (copy (allocate-instance class)))
>       (dolist (slot slot-names)
> 	(setf (slot-value copy slot)
> 	      (slot-value x slot)))
>       copy))


__________________________________________________
Do You Yahoo!?
Yahoo! Sports - Coverage of the 2002 Olympic Games
http://sports.yahoo.com


[long answer] Re: copy-object

Unable to parse email body. Email id is 111

Updated at: 2020-12-10 09:02 UTC