[Openmcl-devel] (SETF FIND-CLASS)
Leslie P. Polzer
sky at viridian-project.de
Wed May 6 03:32:39 EDT 2009
Gary Byers wrote:
> There's a (possibly slightly faster) way of determining that a symbol
> is a type specifier that (properly) names a class. (If it's any faster,
> that'd be because CLASS-NAME is a generic function.)
> Figuring that out (in general, mapping from a type specifier to a
> class or some other representation of a type) as quickly as possible
> is important for things like TYPEP and SUBTYPEP (when they couldn't do
> that simplification at compile-time), but we're talking about the
> expansion of DEFTYPE (CCL::%DEFTYPE) here ... That usually happens at
> load time and isn't much of a bottleneck, so the straightforward check
> for proper-namedness is fine here.
CCL already has proper name handling (not in DEFTYPE though), but I
think it might be flawed.
CLHS's definition of a proper name:
If S is a symbol such that S = (class-name C) and C = (find-class S),
then S is the proper name of C.
So since CLASS-NAME is redefinable by the user there's no way
to circumvent the check against it (except if we were to watch
and record any redefinition of it, obviously).
But the current proper name framework (%class-proper-name,
update-class-proper-names) does not honor this relationship
and just manages the proper name via FIND-CLASS and its setter,
storing it in an internal class slot.
We should probably first get rid of the current code
and replace it with something like this:
(defun %proper-name (class)
"Return the proper name of a class or NIL if there's no proper name."
(let ((name (class-name class)))
(when (eq (find-class name nil) name)
(defun %proper-name-p (name class)
(and class (eq name (%proper-name class))))
Later we can think about a caching mechanism for this if it
turns out to be important.
More information about the Openmcl-devel