[Grace-core] Inconsistent declaration syntax

Kim Bruce kim at cs.pomona.edu
Sat Aug 4 06:30:32 PDT 2012


I don't see the notations as inconsistent as a type declaration is similar to a def, but I consider types as a different category from values, so just use a different keyword (though we could replace def by val ...)

Sent from Kim's iPhone

On Aug 4, 2012, at 7:56 AM, James Noble <kjx at ecs.vuw.ac.nz> wrote:

>> Grace's main declaration syntax is
>> 
>>    def name = <expr>
>> 
>> but for classes we have the shorthand
>> 
>>    class name.meth(..) { ... }
>> 
>> and for types we have the shorthand
>> 
>>    type name = { ... }
>> 
>> 
>> It would make more sense to me to use the same notational convention for types as for classes, or for values  This means that we would either write
>> 
>>    def name = type { ... }
>>    def name = T1 & T2
> 
> So I believe we can write both of these (or at least can in theory :-)
> They set up name as referring to the reified type object.
> But presumably unlike type declarations they can't be used as actual types;
> they can (I imagine) be rather more dynamic.
> 
>> or
>> 
>>    type name <type-expr>
> 
> So allowing 
> 
> type foo bar  
> 
> to alias foo to bar? 
> 
>> Could either of these be made to parse?  What do you think?
> 
> I think all of them could be made to parse, but let's see what "Mr Literal" says :-)
> 
> on the other hand, well there is one other important declaration syntax:
> 
> method foo { bar }   // and various other extensions :-)
> 
> how to we maintain consistency with that? 
> 
> James
> _______________________________________________
> Grace-core mailing list
> Grace-core at cecs.pdx.edu
> https://mailhost.cecs.pdx.edu/mailman/listinfo/grace-core


More information about the Grace-core mailing list