[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
MULTIPLE-VALUE-SETQ and SYMBOL-MACROLET interaction
- To: cl-cleanup@sail.stanford.edu
- Subject: MULTIPLE-VALUE-SETQ and SYMBOL-MACROLET interaction
- From: Barry Margolin <barmar@Think.COM>
- Date: Thu, 28 Jul 88 22:15 EDT
In CLOS, the way to access slots as if they were lexical variables is to
use WITH-SLOTS, which uses SYMBOL-MACROLET to macroexpand occurrences of
the slot names into (SLOT-VALUE <object> '<name>) forms. It also
converts any SETQ special forms into SETF forms.
But what about MULTIPLE-VALUE-SETQ? If SETQ is allowed to assign slot
variables then so should MULTIPLE-VALUE-SETQ. At first I thought this
would require a MULTIPLE-VALUE-SETF, and perhaps that is the right way
to go anyway. However, it could also be done by expanding the
requirement on SYMBOL-MACROLET: it could transform
(multiple-value-setq (<slot> ...) ...)
into
(progn (multiple-value-setq (#:GENSYM ...) ...)
(setf (slot-value <object> '<slot>) #:GENSYM))
This works properly in Symbolics Flavors because
(multiple-value-setq (var1 var2) <form>)
macroexpands into
(multiple-value-call #'(lambda (#:g1 #:g2) (setq var1 #:g1 var2 #:g2)) <form>)
which reduces it to a solved problem. Perhaps the CLOS committee was
assuming that MULTIPLE-VALUE-SETQ includes SETQ's in its expansion, but
this is not actually specified by CLtL.
barmar