[plt-scheme] class.ss questions (newb)

From: Jon Rafkind (workmin at ccs.neu.edu)
Date: Fri Apr 27 22:17:47 EDT 2007


Cyprien Nicolas wrote:
> Hi schemers,
>
> I'm looking for a (copy|clone|duplicate)-object procedure, which name 
> seems to speak for itself.
>
> Does it exists ? or do I have to copy each field one after the other, 
> with taking care of copying values but not pointers ?
>
While I think of a better answer this quick hack might do:

(define (copy v)
  (deserialize (serialize v))

Even in other languages you have to set each field explicitly. Theres 
probably some way of iterating through the fields in a class with a 
macro or something to make it easier. What do you mean by pointers? Boxes?


Posted on the users mailing list.