[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: no-applicable-method

    Date: Thu, 10 Aug 89 10:41 U

    If defining a method for the gen func NO-APPLICABLE-METHOD, specialised
    on STANDARD-GENERIC-FUNCTION is illegal, I assume that specialising
    on the class T is illegal too then since T is specified in CLOS.  

Yes, the following excerpt from the current draft version of chapter 3
(which, unfortunately, still isn't available) may be helpful to you.

  These principles govern inheritance relationships among CLOS classes, and
  the corresponding method applicability relationships of methods specialized
  to those classes.  Other principles which govern the calling relationships
  among generic functions are defined in the ``Protocols'' section.
  These principles are based on a division of classes, methods and generic
  functions into three categories.  Classes, methods and generic functions
  defined by this specification are called {\bit specified classes}, {\bit
  specified methods} and {\bit specified generic-functions}.  Classes, methods
  and generic functions which are defined by a particular implementation of
  CLOS are called {\bit implementation-specific classes}, {\bit
  implementation-specific methods} and {\bit implementation-specific
  generic-functions}.  Classes, methods and generic functions which are
  defined by portable programs are called {\bit portable classes}, {\bit
  portable methods} and {\bit portable generic-functions}.
  \item{4}  Implementations are not free to override a specified method with an
  unspecified method if that will affect the specified method's applicability
  to any specified class.
  \item{5} Implementations are free to define unspecified {\bf :before} and
  {\bf :after} methods on specified generic functions.
  \item{6} Portable programs are not free to redefine any specified methods or
  classes.  Portable programs are not free to define methods on specified
  generic functions which are specialized to specified classes.

    So, when the specification says methods may be written for it, does
    that imply that only methods specialised on a user defined metaclass
    for gf objects may be written?

Yes, if the generic function is a specified one, you can write methods
on user defined metaobject classes only.  So, you could say:

(defclass my-generic-function (standard-generic-function)
  (:metaclass funcallable-standard-class))

(defmethod no-applicable-method ((gf my-generic-function) args)

Then, using defgeneric, you can make a generic function like FOO be an
instance of my-generic-function rather than standard-generic-function.
In the PCL you are using, you may need to say the following instead:

(eval-when (compile load eval)
  (ensure-generic-function 'foo 
                           :generic-function-class my-generic-function))

Or, at the very worst:

(eval-when (compile load eval)
  (unless (fboundp 'foo)
    (setf (symbol-function 'foo)
          (make-instance 'my-generic-function))))