|
|
— |
clips:clip4rea [2010/01/04 19:46] (current) |
| |
| <HTML> |
| <HEAD> |
| <META HTTP-EQUIV="Content-Type" Content="text/html; charset=Windows-1252"> |
| <TITLE>DEFMESSAGE HANDLER</TITLE> |
| </HEAD> |
| |
| <BODY BGCOLOR="#FFFFFF" TEXT="#000000"> |
| |
| <OBJECT TYPE="application/x-oleobject" CLASSID="clsid:1e2a7bd0-dab9-11d0-b93a-00c04fc99f9e"> |
| <PARAM NAME="Keyword" VALUE="DEFMESSAGE-HANDLER"> |
| </OBJECT> |
| |
| <H1><A NAME="defmessage_handler"></A>DEFMESSAGE HANDLER</H1> |
| |
| <P></P> |
| |
| <P>Objects are manipulated by sending them messages via the function send. The </P> |
| |
| <P>result of a message is a useful return-value or side-effect. A </P> |
| |
| <P>defmessage-handler is a construct for specifying the behavior of a class of </P> |
| |
| <P>objects in response to a particular message. The implementation of a message </P> |
| |
| <P>is made up of pieces of procedural code called message-handlers (or handlers </P> |
| |
| <P>for short). Each class in the class precedence list of an object's class can </P> |
| |
| <P>have handlers for a message. In this way, the object's class and all its </P> |
| |
| <P>superclasses share the labor of handling the message. Each class's handlers </P> |
| |
| <P>handle the part of the message which is appropriate to that class. Within a </P> |
| |
| <P>class, the handlers for a particular message can be further subdivided into </P> |
| |
| <P>four types or categories: primary, before, after and around.</P> |
| |
| <P>A defmessage-handler is comprised of seven elements: 1) a class name to which </P> |
| |
| <P>to attach the handler (the class must have been previously defined), 2) a </P> |
| |
| <P>message name to which the handler will respond, 3) an optional type (the </P> |
| |
| <P>default is primary), 4) an optional comment, 5) a list of parameters that will</P> |
| |
| <P>be passed to the handler during execution, 6) an optional wildcard parameter </P> |
| |
| <P>and 7) a series of expressions which are executed in order when the handler </P> |
| |
| <P>is called. The return-value of a message-handler is the evaluation of the last </P> |
| |
| <P>expression in the body.</P> |
| |
| <P>The syntax of the defmessage-handler construct is:</P> |
| |
| <P></P> |
| |
| <PRE><CODE>(defmessage-handler <class-name> <message-name> |
| [<handlertype>] [<comment>] |
| (<parameter>* [<wildcard-parameter>]) |
| <action>*) |
| |
| <handler-type> ::= around | before | primary | after |
| |
| <parameter> ::= <single-field-variable> |
| |
| <wildcard-parameter> ::= <multifield-variable></CODE></PRE> |
| |
| </BODY> |
| </HTML> |
| |