[Grace-core] RFC: Compile-time constants

Michael Homer mwh at ecs.vuw.ac.nz
Fri May 2 02:33:05 PDT 2014


On Fri, May 2, 2014 at 5:55 PM, Timothy Jones <tim at ecs.vuw.ac.nz> wrote:
> We've been talking about the syntax for types and constants, and I've been
> particularly vocal about changing our current approach. Here's a quick summary
> of things so far, so we're all on the same page about why things are as they are
> at the moment.
>
> So type declarations aren't right, and neither are defs. What we need is some
> sort of declaration that means, "this value is statically known". We also need
> different semantics for evaluating these declarations, to handle evaluating them
> in a way that supports both hoisting and mutual recursion (that is, the
> declarations are considered to all appear simultaneously at the top of whatever
> scope they appear in). The semantics are important, and are also the hard part.
>
> First, syntax. Both 'const' and I think 'manifest' have been suggested as the
> opening keyword. I'm not sure if anyone suggested 'static'. Both 'const' and
> 'static' have different meanings across different languages, and I'd rather the
> keyword be shorter than 'manifest'. I quite like using 'let', so I'm going to
> use that for now, and we can have the bikeshedding argument later.
>
>   let MyType<T> = type { thing -> T }
>
>   let aThing = brand
>
>   let Thing = aThing.pattern & type { another -> MyType<Thing> }
>
>   def myThing : Thing = object is aThing {
>     def another is public = object { def thing is public = outer }
>   }
>
> There is more to discuss here, but I don't want to go on too long, and I would
> like some feedback. Andrew mentioned that he would like statically known
> declarations for traits, so I would like to know more about that use case.
It seems like these are what you want for inheritance ("definitively
static") too, so it's worth factoring in what that needs as well.

What is the semantics of "a method that is annotated as static"? Notably:
- What relation does it have to what we might call "final"?
- What is it allowed to refer to?
- Can it be inherited?
- What is it allowed to return?
- What arguments can be given to it?
-Michael


More information about the Grace-core mailing list