[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Initialize-instance
- To: info-mcl@cambridge.apple.com
- Subject: Initialize-instance
- From: jbk@world.std.com (Jeffrey B Kane)
- Date: Mon, 6 Jul 92 10:38:38 -0400
I have another couple of quick CLOS related questions. The first has to do
with defining my own "initialize-instance" method for my classes. For my
simplest example, I didn't need any parameters, so I tried:
(defclass twindow (window)
((garbage :initarg :garbage ; holds some value that I might need
:initform nil
:accessor garbage)))
(defmethod initialize-instance ((me twindow) &rest)
(print "Hi, I'm initializing an instance of a twindow")
(initialize-instance (coerce me window)))
but I am not using the correct lambda list. I've tried looking for examples
of where this is defined in other files, but they don't really address this
simple case. Also, does MCL call this method for me (automatically) or do I
have to explicitly call it every time I create a new instance of my object?
-- for example if I type
(setf wind-1 (make-instance 'window))
As a second question, what is the prefered way of calling an inherited method.
In object pascal I just call
inherited old_method(var1 var2 var3);
in C I need to explicitly call it using the class name:
parentClass::old_method(var1 var2 var3);
Am I doing it correctly in the above example, i.e.
(initialize-instance (coerce me window)))
[I'm trying to call the inherited initialize-instance]
I'm still looking for the CLOS tutorial book. I got the book
"Understanding CLOS" but it seems that it is mostly a rehash of
the specification with little insight into it's actual use.
Too bad I can't park at Quantum Books :)
Jeffrey