next up previous

12.16.2.2 Calling Shadowed Handlers

If the conditions are such that the function next-handlerp would return the symbol TRUE, then calling this function will execute the shadowed method. Otherwise, a message (see section 9.5.4) will occur. In the event of an error, the return value of this function is the symbol FALSE, otherwise it is the return value of the shadowed handler. The shadowed handler is passed the same arguments as the calling handler.

A handler may continue execution after calling call-next-handler. In addition, a handler may make multiple calls to call-next-handler, and the same shadowed handler will be executed each time.

Syntax

(call-next-handler)

Example

CLIPS> (clear)
CLIPS> (defclass A (is-a USER) (role concrete))
CLIPS>
(defmessage-handler A print-args ($?any)
  (printout t "A: " ?any crlf)
  (if (next-handlerp) then
     (call-next-handler)))
CLIPS>
(defmessage-handler USER print-args ($?any)
  (printout t "USER: " ?any crlf))
CLIPS> (make-instance a of A)
[a]
CLIPS> (send [a] print-args 1 2 3 4)
A: (1 2 3 4)
USER: (1 2 3 4)
CLIPS>

12.16.2.3 Calling Shadowed Handlers with Different Arguments

This function is identical to call-next-handler except that this function can change the arguments passed to the shadowed handler.

Syntax

(override-next-handler <expression>*)

Example

CLIPS> (clear)
CLIPS> (defclass A (is-a USER) (role concrete))
CLIPS>
(defmessage-handler A print-args ($?any)
  (printout t "A: " ?any crlf)
  (if (next-handlerp) then
     (override-next-handler (rest$ ?any))))
CLIPS>
(defmessage-handler USER print-args ($?any)
  (printout t "USER: " ?any crlf))
CLIPS> (make-instance a of A)
[a]
CLIPS> (send [a] print-args 1 2 3 4)
A: (1 2 3 4)
USER: (2 3 4)
CLIPS>


next up previous