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

Eric Tanter etanter at dcc.uchile.cl
Mon Nov 7 05:51:56 PST 2011


I'm sorry but I don't see what you're pointing at:

class A {}
class AB extends A { AB get() {return this;} }
class AC extends A { AC get() {return this;} }
A a1 = new AB().get();
A a2 = new AC().get();

I probably misunderstood what you wrote but that's the closest I could get...

-- Éric


On Oct 11, 2011, at 1:32 PM, Andrew P. Black wrote:

> 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