[Grace-core] [A Graceful Blog] Comment: "From Lancaster to Portland"

Andrew P. Black black at cs.pdx.edu
Tue Oct 11 09:32:57 PDT 2011


I believe that the problem is that subtyping in Java is not Compositional.

if AB extends A and AC extends A, 

then 

	type {method m -> AB}

and 

	type{method m -> AC}

do not have

	type{method m -> A}

as a common supertype.

This is because, in general, AB and AC may not have a common supertype.  In Grace, they always will.


On 11 Oct 2011, at 4:19, Eric Tanter wrote:

> Dear all,
> 
> On Sep 26, 2011, at 9:23 PM, Kim Bruce wrote:
>> In fact, as I now recall, we ran into this with an OOPSLA paper where we ran into problems with typing conditional expressions, and we found we needed the entire lattice.  Because Java has conditional expressions, but no sups or infs (because of nominal typing), they do not fully support subtyping.  If expT: A <: C and expE: B <: C then "boolExp? expT: expE" is not typable in Java, even though it clearly has type C.
> 
> I don't understand this -- the following:
> 
> C c = (x < 10) ? new A() : new B();
> 
> does type correctly in Java with A <: C and B <: C
> 
> am I missing something?
> 
> Thanks!
> 
> -- Éric



More information about the Grace-core mailing list