なんだこれは

はてなダイアリーから移転しました。

defun の関数名にあたるところに setfが入っている、SETF関数の宣言のメモ

いろいろと、あちらこちらで、Common lispソースコードを見ていると、こんなものに出会った。

(defun (setf car) (new-car lst)
  (rplaca lst new-car)
  new-car)
(defun cookies-out* (&optional (reply *reply*))
"Returns an alist of the outgoing cookies associated with the REPLY object REPLY."
    (cookies-out reply))

(defun (setf cookies-out*) (new-value &optional (reply *reply*))
"Sets the alist of the outgoing cookies associated with the REPLY object REPLY."
    (setf (cookies-out reply) new-value))

defunの関数名のところに、setfが入っている。なんだろう?
いろいろ見ていると、classを作成したときの、アクセス関数などで使用される、SETF関数の定義だということだった。

続きを読む