[Grace-core] Type declarations

Timothy Jones tim at ecs.vuw.ac.nz
Thu Mar 20 23:28:53 PDT 2014


On 21/03, Kim Bruce wrote:
> 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.

My point is that's it might be ambiguous, depending on what you're allowed to
write on the right hand side. If I have a value which is a static object as far
as my pluggable checker is concerned, I think I should be able to write it on
the right hand side, which means any expression should be allowed there.

> 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.

Heh, they're a little further away on my keyboard. I'm not a not a huge fan of
banana brackets and family (though Michael and I were talking about allowing
user-defined meanings of bracket combinations). I don't mind the type keyword on
the structural literal, as long as it's not the one on the declaration as well.

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

I agree, and would also prefer an alternative, but it needs to be both
consistent and unambiguous.

-- 
Tim


More information about the Grace-core mailing list