[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

declare in with-slots

We never discussed how people could use declare inside of with-slots.  I
don't think we ever thought of it.  But to at least one of my users,
this is a serious bug.  Here is an idea for how to fix this.  I am not
enough of a declaration expert to know if this can work.

All of what I say here also applies to with-accessors.

Allow declarartions to appear in front of the with-slots body.  These
declarations affect the pseudo-bindings performed by the with slots.
They talk about the value which will be returned by evaluating one of the
pseudo variables and the values which will be stored in the pseudo
variables.  The SPECIAL declaration is, of course, now allowed.

So, for example:

(with-slots (x y z) <instance>
  (declare (fixnum x y z))
  (setq z (* x y)))


   (setf (the fixnum (slot-value <instance> 'z))
         (* (the fixnum (slot-value <instance> 'x))
	    (the fixnum (slot-value <instance> 'x)))))

If this makes sense, a cleanup proposal should do the trick.

Note that I didn't layer this directly into symbol-macrolet.  We could
of course put it there, but it seemed to me that it was more appropriate
for this to be something which the caller of symbol-macrolet handles.  I
could pretty easily be convinced that I am wrong about this.