next up previous

8.5.1 Applicability of Methods Summary

An explicit (user-defined) method is applicable to a generic function call if the following three conditions are met: 1) its name matches that of the generic function, 2) it accepts at least as many arguments as were passed to the generic function, and 3) every argument of the generic function satisfies the corresponding parameter restriction (if any) of the method.

Method restrictions are examined from left to right. As soon as one restriction is not satisfied, the method is abandoned, and the rest of the restrictions (if any) are not examined.

When a standard CLIPS system function is overloaded, CLIPS forms an implicit method definition corresponding to that system function. This implicit method is derived from the argument restriction string for the external DefineFunction2 call defining that function to CLIPS (see the Advanced Programming Guide). This string can be accessed with the function get-function-restrictions. The specification of this implicit method can be examined with the list-defmethods or get-method-restrictions functions. The method that CLIPS will form for a system function can be derived by the user from the BNF given in this document. For example,

Syntax: (+ <number> <number>+)

would yield the following method for the ë+í function:

(defmethod + ((?first NUMBER) (?second NUMBER) ($?rest NUMBER))
...)

The method definition is used to determine the applicability and precedence of the system function to the generic function call.

The following system functions cannot be overloaded, and CLIPS will generate an error if an attempt is made to do so.

active-duplicate-instance         delayed-do-for-all-instances message-modify-instance

active-initialize-instance        doforallinstances            modify

active-make-instance              do-for-instance              modify-instance

active-message-duplicate-instance duplicate                    next-handlerp

active-message-modify-instance    duplicate-instance           next-methodp

active-modify-instance            expand$                      object-pattern-match-delay

any-instancep                     find-all-instances           override-next-handler

assert                            find-instance                override-next-method

bind                              if                           progn

break                             make-instance                 progn$

call-next-handler                 initialize-instance           return

call-next-method                  loop-for-count                switch

call-specific-method              message-uplicate-instance     while




next up previous