Question

Suppose I have a class animal, with subclasses horse, duck, and rabbit. Suppose I use make-instance to make several objects of class animal. Much later, I discover, for each of these objects, that it's actually a horse, or a duck, or a rabbit. Is there a way to retype these objects? Simply creating new objects of the appropriate subtypes and copying over the data in all the slots, would be clumsy, because by this time such an object is already represented in lists which are in slots of yet other objects, and I'd have to go through those lists and replace the old objects with the new ones.

Keep the same old objects and subclassify them. Can I do this?

Was it helpful?

Solution

CHANGE-CLASS, a standard Common Lisp function.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top