Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

various ways of defining setf's?

1 view
Skip to first unread message

Peter Seibel

unread,
Dec 27, 2002, 3:51:59 PM12/27/02
to
I've found at least four ways to define the behavior that happens when
I say '(setf (foo x) y)': DEFUN'ing a function named '(setf foo)',
using the short or long form of DEFSETF, or defining an expander with
DEFINE-SETF-EXPANDER. Plus macros that MACROEXPAND-1 into a SETF'able
place, per CLHS 5.1.2.7.

Can someone give me a little guidance as to when to use which style?

-Peter

--
Peter Seibel
pe...@javamonkey.com

Barry Margolin

unread,
Dec 27, 2002, 4:28:58 PM12/27/02
to
In article <m3heczq...@localhost.localdomain>,

Peter Seibel <pe...@javamonkey.com> wrote:
>I've found at least four ways to define the behavior that happens when
>I say '(setf (foo x) y)': DEFUN'ing a function named '(setf foo)',
>using the short or long form of DEFSETF, or defining an expander with
>DEFINE-SETF-EXPANDER. Plus macros that MACROEXPAND-1 into a SETF'able
>place, per CLHS 5.1.2.7.
>
>Can someone give me a little guidance as to when to use which style?

I recommend trying them in the following order until you get to the one
that meets your needs: a (setf foo) function, short DEFSETF, long DEFSETF,
DEFINE-SETF-EXPANDER. Basically, this is increasing order of complexity.

All these mechanisms exist for historical reasons. The DEF macros were
there first, for the most flexibility. The (setf foo) functions were a
late addition, created to fill a need in CLOS, but they turn out to be the
simplest mechanism (but they can't do everything that the macros can).

--
Barry Margolin, bar...@genuity.net
Genuity, Woburn, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.

0 new messages