[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: defstruct, slot-accessors, and setf
- To: firstname.lastname@example.org
- Subject: Re: defstruct, slot-accessors, and setf
- From: email@example.com (Bill St. Clair)
- Date: Thu, 14 May 1992 12:26:38 -0500
- Cc: info-mcl
>CLtL2 allows setf functions to be accessed with #'(setf ...).
>In MCL2.0 (f2) setf accessors for structures cannot be denoted by
>(defstruct ship x y)
>(describe #'ship-x) ;; ok
>(describe #'(setf ship-x)) ;; bang!
>I would to suggest to use these setf functions ananogously to those
>defined with defun (defun (setf ship-z) (...) ...).
setf functions which are defined by:
(defun (setf foo) (new-value &rest args) ...)
may indeed be accessed with #'(setf foo). The :accessors slot
keyword to DEFCLASS creates its accessors this way.
setf accessors that are defined with DEFSETF do NOT work that way.
They store some state in tables that the SETF macro looks at to
tell it how to macroexpand.
We chose to make DEFSTRUCT work by interacting with the SETF macro
rather than by creating SETF functions. This is largely historical;
#'(setf foo) was not part of Common Lisp when the DEFSTRUCT code
was written. I think that it's still the right approach, though.
DEFSTRUCT already peppers your environment with function definitions
Adding one more for each slot seems a bit excessive to me.