Hi,
An issue with forward referenced classes has come up, and although I
think the semantics for this are well-defined, this doesn't seem to be a
clear-cut case.
Assume the following class definition.
(defclass class1 (class2) ())
Assume that class2 does not refer to any class at the time this defclass
form is evaluated. According to the HyperSpec, it is permitted to define
class2 afterwards, so that the order in which classes are defined
doesn't have to follow the actual order in the class hierarchy.
In such a situation, what are the following forms supposed to return?
#|1|# (subtypep 'class1 'class2)
#|2|# (subtypep 'class2 'class2)
#|3|# (subtypep 'class2 'standard-object)
I am pretty sure that forms 1 and 2 should return (values t t).
Form 3 is not so straightforward, but my understanding of Section 4.3.1
and 4.3.7 of the HyperSpec is that this should return (values nil t).
The reason for this is that at the time of evaluating the subtypep form,
standard-object does not occur in the direct and indirect superclasses
of class2. In fact, there are no direct or indirect superclasses. Since
the subtyping relationship for classes is defined in terms of the
subclassing relationship, which in turn is defined in terms of direct
and indirect super- and subclasses (and doesn't require well-defined
class precedence lists!). Finally, we cannot assume that standard-object
will become one of the superclasses sooner or later, because this
depends on the metaclass of class2 which is not know yet.
These results would also all be consistent with the CLOS MOP specification.
The CLOS implementations that I have at hand either do the Right Thing
(tm) ;), or issue an error because class2 is not considered a proper class.
Most implementors to which I have reported this issue have acknowledged
it and provided fixes, or intend to work on it.
One exception are the clisp implementors who claim that the subtyping
relationship for forward referenced classes is _not_ well-defined, but
to the contrary violate the HyperSpec. Furthermore, they claim that the
CLOS MOP specification is inconsistent with the HyperSpec in this
regard. However, I have problems to understand how one could come to
this conclusion. (You can follow the discussion with the clisp
implementors so far at
http://sourceforge.net/tracker/index.php?func=detail&aid=1591671&group_id=1355&atid=101355
)
Does anyone have an opinion on this?
Thanks,
Pascal
--
My website: http://p-cos.net
Common Lisp Document Repository: http://cdr.eurolisp.org
Closer to MOP & ContextL: http://common-lisp.net/project/closer/