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

Re: redefining methods

    Date: Sun, 18 Sep 88 22:37:08 edt
    From: eliot%winnie.Princeton.EDU@Princeton.EDU (eliot handelman)

    You can get the error like this:

    (defun foo (x) nil)
    (defclass baz () ((s :accessor foo)))

This code is illegal according to the CLOS specification.  On page 2-46,
in the description of ensure-generic-function says:

  If (SYMBOL-FUNCTION <identifier>) is a non-generic function,
  a macro or a special form, an error is signalled.

The reason for this, is that defmethod (and ensure-generic-function)
believe that they help to build generic function definitions
incrementally.  When they see a normal function, they have no way to
know how to have its definition contribute to the definition of the
whole function.  

What you *may* want to do is:

(defun foo (x) nil)

(eval-when (load eval)
  (pcl::make-specializable 'foo :arglist '(x)))

(defclass baz ()
    ((s :accessor foo)))