Re: How do I add an extra slot to a class?



Saurabh Nanda wrote:
:DEFAULT-INITARGS are not the same as the :INITARG forms passed to
slots in DEFCLASS. See section 7.1 in the HyperSpec for a
clarification.

Sorry my goof up. So I guess I'll have to use class-slots to get all the slots of the class. For each slot I will have to use slot-definition-initargs, slot-definition-readers, slot-definition-writers, etc. to get the various slot options. Using all this info I'll have to construct the lambda list for reinitialize-instance and call it for the class in question.

Wow! Why isn't there a simple macro for this already!

I had to learn this the hard way - this is exactly what I originally did in AspectL, and it's wrong (to give the executive summary here ;).

You're walking on very thin ice here, and you seem to be using a try-and-error approach. You should, at least, first read the Concepts chapter of the CLOS MOP specification and understand the essentials of MOP programing before proceeding. (No, you don't use the class-slots here, but the class-direct-slots, and by reading the Concepts chapter, such things, and others, should become clear to you.)

It would be even better to get a copy of AMOP and read it. It's an excellent and very insightful book (one of the best computer science books according to Alan Kay). There is a reason why the CLOS MOP doesn't support class definition by way of setter functions or reinitialize-instance that well, and the reason is given there.


Pascal

--
My website: http://p-cos.net
Common Lisp Document Repository: http://cdr.eurolisp.org
Closer to MOP & ContextL: http://common-lisp.net/project/closer/
.