[Grace-core] Inconsistent declaration syntax
James Noble
kjx at ecs.vuw.ac.nz
Sat Aug 4 04:56:58 PDT 2012
> 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
More information about the Grace-core
mailing list