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

[kempf%Sun:COM:Xerox: CLOS Slot Subclassing Rule Violates Contravariance]



     ----- Begin Forwarded Messages -----

Date: 31 Mar 89 13:53 PST
From: kempf%Sun:COM:Xerox
Subject: CLOS Slot Subclassing Rule Violates Contravariance
To: masinter:PA:Xerox


Larry:

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
respected.

The upshot is that slot subtyping either be done right or it not be done
at all.

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.

		jak




     ----- Next Message -----

Date:  3 Apr 89 14:10 PDT
From: masinter:PARC:Xerox
Subject: Re: CLOS Slot Subclassing Rule Violates Contravariance
In-Reply-to: kempf%Sun:COM's message of Friday, March 31, 1989  1:53 pm
To: kempf%Sun:COM:Xerox

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
different goal?

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 -----