On Nov 30, 2010, at 10:32 PM, Nadeem Abdul Hamid wrote:
> I think something like this has come up before but I can't find the
> thread. Given:
>> (define A%
> (class object% (inspect #f) (super-new)))
> (define/contract B%
> (class/c )
> (class object% (inspect #f) (super-new)))
>> How can I get around the problem that:
> (equal? (new A%) (new A%))
> but
> (not (equal? (new B%) (new B%)))
>> I want to be able to compare objects of the same contracted class for
> structural equality.
This is indeed a problem with the current implementation of class/c. I'm currently working on reimplementing parts of our contract system to take advantage of the new chaperone and impersonator wrappers. Once class/c is rewritten, I believe that this problem will just go away, since all the information about which inspectors have access (or that all inspectors have access, in this case) should be preserved. Feel free to submit a bug in the meantime, so that I'll have a reminder to check that this has indeed been solved once I've finished.
> And another question: is there something similar to struct-copy for
> objects? Or a way to easily clone them?
No, though this has been a requested feature before; I know that Ryan has done some work in this area before, but I haven't had a chance at incorporating what he's done, or something similar, into the core class system yet. It is on my list, though. Submit a bug report about this, and it'll be easier for me to keep track of it for future work.
Thanks,
Stevie