Re: using 2 or more arguments in a setf method



On Dec 30, 2:39 pm, Joost Diepenmaat <jo...@xxxxxxxxx> wrote:
[snip]

I tried the following in SBCL:

(defmethod (setf input-buffer) (buffer (patch my-class) key)
(setf (getf (input-buffers patch) key) buffer))

But that gives me an error:

The generic function
#<STANDARD-GENERIC-FUNCTION (SETF INPUT-BUFFER) (2)> takes 2
required arguments; was asked to find a method with specializers
(#1=#<BUILT-IN-CLASS T> #<STANDARD-CLASS LADSPA-PATCH> #1#)
[Condition of type SB-PCL::FIND-METHOD-LENGTH-MISMATCH]
See also:
Common Lisp Hyperspec, FIND-METHOD [:function]

As far as I can make out, that seems to indicate that you can't setf
on a method that takes more than one argument.

You didn't make out far enough. This error indicates that the generic
function (SETF INPUT-BUFFER) is already defined with less arguments
than in your method definition. You've probably defined an accessor
somewhere, like in the definition of one of your class's slots.

* (defmethod (setf input-buffer) (val (class t) thing otherthing &rest
things)
(declare (ignore thing otherthing things))
t)
#<STANDARD-METHOD (SETF INPUT-BUFFER) (T T T T) {9493EA9}>


hth,

drewc



It does work if I use a normal method instead of a setf method but I
don't think it's as nice to look at when I can use setf in other places:

(defmethod set-input-buffer ((patch my-class) key buffer)
(setf (getf (input-buffers patch) key) buffer))

Is there any way I can get the setf version to work?

Joost.

.



Relevant Pages

  • using 2 or more arguments in a setf method
    ... I'm beginning to suspect that I'm missing something about setf methods ... I've got a simple method that retrieves a buffer from an object by a key ... (setf (getf (input-buffers patch) ...
    (comp.lang.lisp)
  • Re: dynamic binding of standard input?
    ... ((buffer:initform nil:accessor buffer))) ... (read-from-msgbox s))) ... (setf (elt new 0) ...
    (comp.lang.lisp)