From: Brian C. Forney
Subject: Problems with :around methods
Date: 
Message-ID: <bforney-0408951553560001@hedon.eecs.umich.edu>
I'm writing some Lisp methods to check tolerances. There are several
different methods which need to be written for different argument types.
Two of the arguments could be nil or the :infinity, so four methods could
be written for these cases, e.g.

(defmethod WITHIN-RELATIVE-TOLERANCE? ((p1 (eql nil)) p2 (tolerance number))
  ....

(defmethod WITHIN-RELATIVE-TOLERANCE? (p1 (p2 (eql nil)) (tolerance number))
  ....

I've tried using the :around keyword and call-next-method to create a
method which checks for the cases and returns nil whenever either p1 or p2
are nil or :infinity. If this condition is not true, call-next-method is
invoked.

Here's the method:

(defmethod WITHIN-RELATIVE-TOLERANCE? :around (p1 p2 tolerance)
  (cond ((eql p1 :infinity))
        ((eql p2 :infinity))
        ((and p1 p2) (call-next-method p1 p2 tolerance))))

When this method is invoked, MCL 2.0.1 displays this error message:
> Error: No applicable primary methods for #<STANDARD-GENERIC-FUNCTION
WITHIN-RELATIVE-TOLERANCE? #xD3DD86>
>        Applicable methods: (#<STANDARD-METHOD WITHIN-RELATIVE-TOLERANCE?
:AROUND (T T T)>)
> While executing: CCL::%METHOD-COMBINATION-ERROR

What am I doing wrong?

-----------------------------------------------
Brian C. Forney
University of Michigan, Computer Engineering