The defmethod macro

The evaluation or execution of a defmethod form requires first that the body of the method be converted to a method function. This process is described in the next section. The result of this process is a method function and a set of additional initialization arguments to be used when creating the new method. Given these two values, the evaluation or execution of a defmethod form proceeds in three steps. The first step ensures the existence of a generic function with the specified name. This is done by calling the function ensure-generic-function. The first argument in this call is the generic function name specified in the defmethod form. The second step is the creation of the new method metaobject by calling make-instance. The class of the new method metaobject is determined by calling generic-function-method-class on the result of the call to ensure-generic-function from the first step. The initialization arguments received by the call to make-instance are as follows: In the third step, add-method is called to add the newly created method to the set of methods associated with the generic function metaobject. The result of the call to add-method is returned as the result of evaluating or executing the defmethod form. An example showing a typical defmethod form and a sample expansion is shown in this figure. The processing of the method body for this method is shown in this figure.