[Grace-core] Type declarations

Kim Bruce kim at cs.pomona.edu
Thu Mar 20 22:59:26 PDT 2014


On Mar 21, 2014, at 9:27 AM, Andrew P Black <black at cs.pdx.edu> wrote:

> 
> On 20 Mar 2014, at 18:23 , James Noble <kjx at ecs.vuw.ac.nz> wrote:
> 
>>> That said, I LIKE using type to mean set of methods and with their types.  I believe that it's what type OUGHT to mean, in an OO language.  But the "type theorists" don't agree ...

I'm not sure which type theorists you mean.  Almost all theoretical work in OO languages (at least in the 90s) used structural types and types meant the set of public methods and their types.

>> 
>> and that's what it means in Grace, and will continue to mean in Grace. 
> 
> 
> Good.  Hence my proposal that we write
> 
> 	const Boolean = type {&& (SelfType) -> SelfType, || (SelfType) -> SelfType, ... }
> 
> const is like def, but you can't override it in sub-objects,  and the value must be knowable at compile time.
> 
> 	Andrew
> 

I'm also unhappy with the change we recently adopted (and I'm not thrilled with Tim's proposal either).  I'd be happy saying that only type names could be used to associate types with constants, variables, and methods, and thus only the right hand side of type definitions include type expressions.  This eliminates all ambiguity (I believe) and leads to simple clear syntax.  Thus,

type S = T & {...}
is perfectly fine, while
var a:{...} := ...
is not.

If that is not acceptable, my second choice would be to write types with {|...|}.  It has the advantage of being easy to type (the keys are both shifted and are right next to each other on the keyboard) and look very much like object definitions.

I don't like using both type and interface as it will be hard for students to know when to use each.

Kim
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailhost.cecs.pdx.edu/pipermail/grace-core/attachments/20140321/68b4c105/attachment.html>


More information about the Grace-core mailing list