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

Re: :accessor-prefix bug

>  * intern the symbols in the package of the prefix symbol
>  - often, this is likely to solve the problem presented in the second
> bullet, but it won't work in general and is kind of a crock.

Is there any logical justification for why this solution won't work?
:Accessor-prefix could be considered to be supplying not only part of the
name, but also the default package.  I certainly find this:

(defclass my::foo ()
  (:accessor-prefix my::foo-))

preferable to:

(defclass my::foo ()
  ((lisp::list :accessor my::foo-list)
   (my::element :accessor my::foo-element)

There are also some of us who still refuse to use prefixes on slot
accessors because they obscure the genericness we are trying to achieve
through subclassing.  I don't want to have to remember that certain slots
of a class are accessed with that class name as a prefix, and other slots
are accessed with some parent classes name for a prefix.  In this case I
find :accessor-prefix NIL to be an invaluable shorthand to enumerating
every slot name twice, once for the slot itself and once for the accessor

If by taking away :accessor-prefix you're trying to keep us from being lazy
(and inadvertantly defining accessors for slots that shouldn't have them by
indiscriminant use of :accessor-prefix) perhaps this reason should be
officially stated.

Regarding with-slots: I've recently heard that in the future you're going
to have to enumerate the slots you want to use in a with-slots form.  I
find the thought of doing this repulsive.  Most of my methods tend to take
the form:

(defmethod m ((f foo) ...)
  (with-slots ((f :use-accessors nil))

and thus behave like classical methods anyway.  This isn't because I don't
know how to use multimethods (I use them when appropriate), but because
classical methods in general are what you want 80% of the time.  The use of
"with-slots ... :use-accessors nil" (or slot-value for that matter) in CLOS
is not just an ugly "back door" that violates encapsulation or is used for
optimization, but is a necessity when specializing slot accessor methods.

I haven't heard a good argument for denying methods on a class privileged
access to that class's slots (of course multimethods complicates this, but
that what :prefix is for), so I don't think taking away with-slots (by
making it so painful to use) is the thing to do.  Perhaps examples of
problematic usage of with-slots and its :prefix option could shed some