next up previous

12.15.8 Calling a Specific Method

The function call-specific-method allows the user to call a particular method of a generic function without regards to method precedence. This allows the user to bypass method precedence when absolutely necessary. The method must be applicable to the arguments passed. Shadowed methods can still be called via call-next-method and override-next-method.

Syntax

(call-specific-method <generic-function> <method-index>
                      <expression>*)

Example

CLIPS> (clear)
CLIPS>
(defmethod + ((?a INTEGER) (?b INTEGER))
  (* (- ?a ?b) (- ?b ?a)))
CLIPS> (list-defmethods +)
+ #2  (INTEGER) (INTEGER)
+ #SYS1  (NUMBER) (NUMBER) ($? NUMBER)
For a total of 2 methods.
CLIPS> (preview-generic + 1 2)
+ #2  (INTEGER) (INTEGER)
+ #SYS1  (NUMBER) (NUMBER) ($? NUMBER)
CLIPS> (watch methods)
CLIPS> (+ 1 2)
MTH >> +:#2  ED:1 (1 2)
MTH << +:#2  ED:1 (1 2)
-1
CLIPS> (call-specific-method + 1 1 2)
MTH >> +:#SYS1  ED:1 (1 2)
MTH << +:#SYS1  ED:1 (1 2)
3
CLIPS> (unwatch methods)
CLIPS>


next up previous