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

RE: decalre in with-slots



> We never discussed how people could use declare inside of with-slots.  I
> don't think we ever thought of it. 

My problem all along with with-slots and symbol-macrolet has been that they
haven't been thought through.  It's not simple to mount this charade that slots
are "just like" variables.  I've come in too late on this work to have said
this earlier, but I will predict now that you will find still other problems
with symbol-macrolet as time goes by.


As to the suggested patch:  No, it won't really work.  Declare's are pretty
much the province of special forms, and with-slots et al won't, in general, be
able to parse the declare's, let alone interpret them correctly.  For example,
a common extension to declare allows:

(deftype t-terminated-list () '(or cons (member t)))

(with-slots (x y z) <instance>
  (declare (t-terminated-list y))
  ...)

In Common Lisp, you can't tell that t-terminated-list is a type, and, even if
you could, you couldn't be sure that this meant 
(declare (type t-terminated-list y)).  (It might mean (declare (ftype ...)), 
which would have nothing at all to do with the _variable_ y.)

While you're thinking about this, consider what would happen if Common Lisp
were extended to allow:

(with-slots (x y z) <instance>
  ...
  (locally (declare (fixnum y))
    ...)
  ...)

[CL doesn't currently allow this, but there's some sentiment to make this
extension.]  Now with-slots would have to parse the entire body to get this
right. 
 
> 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.
 
What's the point of symbol-macrolet, then, if not to be the form which says
"pretend foo is a variable, even though it's not"?  You're suggesting that only
with-slots wants to play "let's pretend," and that there's some different roles
that symbol-macrolet fills?  I doubt it...

/JEP