[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[kempf%Sun:COM:Xerox: CLOS Slot Subclassing Rule Violates Contravariance]
- To: common-lisp-object-system@SAIL.STANFORD.EDU
- Subject: [kempf%Sun:COM:Xerox: CLOS Slot Subclassing Rule Violates Contravariance]
- From: masinter.pa@Xerox.COM
- Date: 6 Apr 89 16:54 PDT
----- Begin Forwarded Messages -----
Date: 31 Mar 89 13:53 PST
Subject: CLOS Slot Subclassing Rule Violates Contravariance
The CLOS rules for subtyping a slot violate contravariance. This means
that it is possible to type check a slot access and still end up getting
a no matching method message at run time.
I personally believe that this should be fixed, however, I am not prepared
to invest any time in it, because I suspect there are a number of
people on the committee (perhaps you among them?) who don't particularly
care whether this is a problem, since Common Lisp is by nature untyped.
This argument would maintain that no matching methods at run time are
OK, even if the compiler tries to get rid of them.
I'm prepared to submit a proposal, but, I don't plan to get into
a fruitless argument about whether types are good or bad. The proposal
would have the following suggestions to eliminate the problem:
1) Slot typing be removed from CLOS. All slots are therefore untyped.
2) The typing rules be tightened up so that contravariance is
The upshot is that slot subtyping either be done right or it not be done
Incidently, something similar can happen with methods, but I think
the argument for dynamic binding is stronger because the need for
optimization is less critical.
----- Next Message -----
Date: 3 Apr 89 14:10 PDT
Subject: Re: CLOS Slot Subclassing Rule Violates Contravariance
In-Reply-to: kempf%Sun:COM's message of Friday, March 31, 1989 1:53 pm
I think the goal was to make it compatible with :TYPE in defstruct.
Xerox Common Lisp used :TYPE in defstruct to allow for compact structures.
I don't understand how the CLOS rules for subtyping a slot violates
contravariance and how this could mean that it is possible to type check a
slot access and still end up getting a no matching method message at run
time. I thought the goal of slot typing was to allow for specialized
storage for some kinds of types. Maybe you're trying to optimize a
In any case, whether you have a formal proposal or an informal one, you
should discuss this on the common-lisp-object-system mailing list and see
if you can get a couple of other people to agree with you.
----- End Forwarded Messages -----