; I have a question about funcalling.
; Let's say that I have this:
(defclass test ()
((test-slot :accessor test-slot :initform 'empty)))
(defun read-slot (fn object)
(format t "~A" (funcall fn object)))
(read-slot #'test-slot (make-instance 'test))
; All this works as expected. But when I define:
(defun set-slot (fn object)
(setf (funcall fn object) 'filled))
; I get an error: Couldn't find a setf
; expansion for (FUNCALL FN OBJECT).
; What would you suggest I do if I want to
; pass a the writer method to a function
; to be funcalled? (The example is a little
; contrived - I just am curious about
; error and I'm looking for a workaround).
; Thanks.
Oh, thanks anyway, but I found a clear post in google groups by Barry
Margolin that describes how to do this.
··········@eudoramail.com (Rand Sobriquet) wrote in message news:<····························@posting.google.com>...
> ; I have a question about funcalling.
>
> ; Let's say that I have this:
>
> (defclass test ()
> ((test-slot :accessor test-slot :initform 'empty)))
>
> (defun read-slot (fn object)
> (format t "~A" (funcall fn object)))
>
> (read-slot #'test-slot (make-instance 'test))
>
> ; All this works as expected. But when I define:
>
> (defun set-slot (fn object)
> (setf (funcall fn object) 'filled))
>
>
> ; I get an error: Couldn't find a setf
> ; expansion for (FUNCALL FN OBJECT).
>
>
> ; What would you suggest I do if I want to
> ; pass a the writer method to a function
> ; to be funcalled? (The example is a little
> ; contrived - I just am curious about
> ; error and I'm looking for a workaround).
> ; Thanks.
Rand Sobriquet writes:
> Oh, thanks anyway, but I found a clear post in google groups by Barry
> Margolin that describes how to do this.
[...]
> ··········@eudoramail.com (Rand Sobriquet) wrote in message news:<····························@posting.google.com>...
[...]
>> ; What would you suggest I do if I want to
>> ; pass a the writer method to a function
>> ; to be funcalled? (The example is a little
Can you provide the message ID of Barry's article?
Paolo
--
Why Lisp? http://alu.cliki.net/RtL%20Highlight%20Film
Paolo,
It's a short post:
<··················@burlma1-snr1.gtei.net>
(Hope that's what a message id looks like. I just searched for
"funcall" and "writer method")
Paolo Amoroso <·······@mclink.it> wrote in message news:<··············@plato.moon.paoloamoroso.it>...
> Rand Sobriquet writes:
>
> > Oh, thanks anyway, but I found a clear post in google groups by Barry
> > Margolin that describes how to do this.
> [...]
> > ··········@eudoramail.com (Rand Sobriquet) wrote in message news:<····························@posting.google.com>...
> [...]
> >> ; What would you suggest I do if I want to
> >> ; pass a the writer method to a function
> >> ; to be funcalled? (The example is a little
>
> Can you provide the message ID of Barry's article?
>
>
> Paolo
··········@eudoramail.com (Rand Sobriquet) writes:
> ; What would you suggest I do if I want to
> ; pass a the writer method to a function
> ; to be funcalled? (The example is a little
> ; contrived - I just am curious about
> ; error and I'm looking for a workaround).
> ; Thanks.
You need to actually pass the writer generic function. This works in
ACL and MCL. A check of the Hyperspec confirms that (SETF <name>) is
valid as a function name, and therefore is a legal argument to the
FUNCTION special form, and by extension to #'
(setq ii (make-instance 'test))
==> #<TEST @ #x469be62>
(test-slot ii)
==> EMPTY
(funcall #'(setf test-slot) 'full ii)
==> FULL
(test-slot ii)
==>
--
Thomas A. Russ, USC/Information Sciences Institute