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

James Noble kjx at ecs.vuw.ac.nz
Tue Nov 8 00:09:50 PST 2011


> that is, the type t with a get method which answers a value of that very type t.

which, I think, after talking to Kim, would be { get -> SelfType }   ? 

> 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();


In Grace, classes don't define types (although you may be able to get 
at them indirectly via something like "typeof(A.new)" )

If the type is {get -> SelfType} then AB.new.get and AC.new.get
would only be assignable some variable A because A, AB &AC
all have exactly the _same_ type { get -> SelfType }  

because we are looking at SelfType being an exact type, not susceptible to subtyping...

James







More information about the Grace-core mailing list