[Grace-core] Modules & Inheritance

Andrew P. Black black at cs.pdx.edu
Thu Oct 18 17:12:42 PDT 2012


On 18 Oct 2012, at 15:18 , Kim Bruce wrote:

> My concern is the following
> 
> def T = {type t, m:...}
> 
> def o1 = object {
>                     type t = {a ... b...}
>                     method m ....
>                }
> 
> def o2 = object {
>                     type t = {c ... d...}
>                     method m ....
>                }
> 
> method p(o:T) {
>     var x: o.t
> }
> 
> Now I don't know whether o.t has methods a and b or methods c and d.

Right.  And what I'm suggesting is that in this case, where o is not statically known, we either

	(1) disallow o.t  with a message like "o not manifest"

or 

	(2) allow it, but make it mean T.t, that is, take the t from the declared type of o.   This seems weird, but I don't think that it is, really.  Presumably, the actual t's in o1 and o2 would have to conform to T.t, or else I couldn't pass o1 and o2 as arguments to p.  So typing x as T.t might be weaker than using o1.t or o2.t, but not incompatible.

You might say, if we are going to do either of the above, my allow types in objects?  My answer is: to solve the problem that you outlined in your long email, and allow the use of objects as modules.

	Andrew



More information about the Grace-core mailing list