using 2 or more arguments in a setf method



I'm beginning to suspect that I'm missing something about setf methods
in CLOS, or maybe I'm just overlooking something simple:

I've got a simple method that retrieves a buffer from an object by a key

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

and I would like this method to be setf-able:

(setf (input-buffer patch 'my-key) new-buffer)

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.

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