:answer
type: message selector location: built-in source file: xlobj.c Common LISP compatible: no supported on: all machines
SYNTAX
(send <class> :answer <message> <args> <code> )
<class> - an existing class
<message> - the message symbol
<args> - formal argument list to the <msg> method
of the same form as a lambda argument list
<code> - a list containing the method code
DESCRIPTION
The :ANSWER message selector adds or changes a method in the specified <class>. This method consists of the <message> selector symbol, the <arg> formal argument list and the executable code associated with the <message>.
EXAMPLES
(setq myclass (send class :new '(var))) ; create MYCLASS with VAR
(send myclass :answer :isnew '() ; set up initialization
'((setq var nil) self))
(send myclass :answer :set-it '(value) ; create :SET-IT message
'((setq var value)))
(send myclass :answer :mine '() ; create :MINE message
'((print "hi there")))
(setq my-obj (send myclass :new)) ; create MY-OBJ of MYCLASS
(send my-obj :set-it 5) ; VAR is set to 5
(send my-obj :mine) ; prints "hi there"
NOTE: When you define a <message> in a <class>, the <message> is only valid for instances of the <class> or its sub-classes. You will get an error if you try to send the <message> to the <class> where it was first defined. If you wish to add a <message> to the <class>, you need to define it in the super-class of <class>.
MESSAGE STRUCTURE: The normal XLISP convention for a <message> is to have a valid symbol preceeded by a colon like :ISNEW or :MY-MESSAGE. However, it is possible to define a <message> that is a symbol without a colon, but this makes the code less readable.