[Grace-core] Modules & Inheritance

Andrew P. Black black at cs.pdx.edu
Thu Oct 18 14:58:09 PDT 2012


On 18 Oct 2012, at 11:10 , Kim Bruce wrote:

> First, one thing that I don’t think we’ve every made clear.  Type definitions should not be considered components of objects.  Objects have defs, variables, and methods, but not type components.  This is important for keeping us out of dependent type systems like Scala.  I don’t want to have to type-check code like
>    method m(o:SomeType) -> OtherType {
>         var x: o.t
>>   }
> Type definitions have static scope like other definitions, but are otherwise treated mainly as abbreviations.  Hopefully this is not controversial.  Yet, as you'll see, this has major implications if we want to treat modules as objects.
> 
> The bottom line for me is that type expressions need to be statically determinable.

Kim, you mentioned this via Skype to me just now, and I nodded "yes", but having thought about it for the time that it took for me to go to the men's room, I don't see the problem.

I agree with your bottom line: type expressions need to be statically determinable.  But this can be accomplished simply by making types in objects non-virtual.  So, in your example, the type component of o would be specified statically in SomeType, and, for the purposes of static type checking, that (Sometype.t) is what gets used.  So long as t can't be changed in sub-objectsof o, I don't see a problem.

Of course, one might object that the whole point of putting types inside objects is exactly to make them virtual, but that isn't the case.  If we are using objects to make modules, it has the value of allowing us to name types using the dot notation.

	Andrew





More information about the Grace-core mailing list