[Grace-core] Type syntax

Kim Bruce kim at cs.pomona.edu
Fri Feb 7 14:00:18 PST 2014


What is the definition of Collection in your example?  Your definition in collections.grace in GUnit looks different:

type IndexableCollection = {
    size -> Number
    at -> Object
}

type Collection = {
    size -> Number
    contains(a) -> Boolean
}

I'm trying to figure out the definition that you say doesn't work.

Kim



On Feb 7, 2014, at 11:48 AM, Andrew P. Black <apblack at ownmail.net> wrote:

> 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.
> 
> _______________________________________________
> Grace-core mailing list
> Grace-core at cecs.pdx.edu
> https://mailhost.cecs.pdx.edu/mailman/listinfo/grace-core

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailhost.cecs.pdx.edu/pipermail/grace-core/attachments/20140207/4dd884c2/attachment.html>


More information about the Grace-core mailing list