[Grace-core] Type syntax

Andrew P. Black apblack at ownmail.net
Fri Feb 7 11:48:50 PST 2014


I’ve posted a proposed resolution at the bottom of the wiki page:  https://projects.cecs.pdx.edu:8443/~black/NewOOL/index.cgi/wiki/RevisedTypeSyntax
and appended to this message.

I think that this solves the immediately problem.  However, in our discussions, we have identified two more:

	(1) Overloading of ->, as Kim says below.
	(2) Too many parameter syntaxes.  Methods, types and blocks can all have parameters, and we use a different syntax for each.  Having three parameter syntaxes is neither Graceful nor simple.


On 7 Feb 2014, at 11:20, Kim Bruce <kim at cs.pomona.edu> wrote:

> Is the main issue expressions like {a:Number -> a*a) which could be interpreted as an anonymous function or a type with method a with type Number -> a*a?
> (Admittedly we wouldn't have a*a as a type, but you get the idea.)


Proposed Resolution

Andrew Proposes the following resolution:

On the right-hand-side of a type declaration
type NewTypeName = type { meth1(args) -> results; meth2(args2) -> results2 }
it is permissible to omit the second type keyword. To be omittable, type must appear immediately after = and immediately before { .
In all other cases, type literals always start with the word type
So, for example, we would write:

type IndexableCollection =  Collection & type { at(ix:Number) -> Element; at(ix:Number) put(e:Element) }
where the second type is compulsory.

(As an aside, the above definition doesn't work, because IndexableCollection needs to match Collection: they need the same element type and SelfType. I'll leave that to the type theoreticians to figure out.)

This continues to distinguish type declarations from other declarations, and thus we can continue to allow type parameters in these declarations.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailhost.cecs.pdx.edu/pipermail/grace-core/attachments/20140207/8cfa81d5/attachment-0001.html>


More information about the Grace-core mailing list