考虑到这段代码:
(defclass test () ((test :initform nil :accessor test)))
#<STANDARD-CLASS TEST>
(defvar *test* (make-instance 'test))
*TEST*
这个测试:
(funcall #'test *test*)
nil
人们会期望这有效:
(setf (funcall #'test *test*) 123)
一样
(setf (test *test*) 123)
123
但这会导致:
; in: LAMBDA NIL
; (FUNCALL #'(SETF FUNCALL) #:NEW1175 #:TMP1177 #:TMP1176)
; ==>
; (SB-C::%FUNCALL #'(SETF FUNCALL) #:NEW1175 #:TMP1177 #:TMP1176)
;
; caught WARNING:
; The function (SETF FUNCALL) is undefined, and its name is reserved by ANSI CL
; so that even if it were defined later, the code doing so would not be portable.
;
; compilation unit finished
; Undefined function:
; (SETF FUNCALL)
; caught 1 WARNING condition
为什么它不起作用,我该如何解决它?
我使用 SBCL 和 CLISP 对其进行了测试,结果相同。