在 Common Lisp 中为 setf 函数定义别名



根据这个问题,可以像这样创建函数的别名:

(defun some-function () ...)
(setf (fdefinition 'sfunc) #'some-function)

但:

(defun some-function () ...)
(defun (setf some-function) () ...)
(setf (fdefinition 'sfunc) #'some-function)
> (setf (sfunc) ...)
; caught STYLE-WARNING:
;   undefined function: (SETF SFUNC)

不会为 setf 函数创建别名。如何为 setf 函数创建别名?

(setf (fdefinition '(setf sfunc)) (fdefinition '(setf some-function)))

最新更新