[Grace-core] RFC: Compile-time constants

Michael Homer mwh at ecs.vuw.ac.nz
Fri May 2 15:58:15 PDT 2014


On Sat, May 3, 2014 at 12:43 AM, Timothy Jones <tim at ecs.vuw.ac.nz> wrote:
> On 02/05, Michael Homer wrote:
>> It seems like these are what you want for inheritance ("definitively
>> static") too, so it's worth factoring in what that needs as well.
>
> I disagree (with the spec, I suppose) that this should even be a thing. An
> invalid inheritance chain should be a runtime error. If a dialect wants to check
> this (as the type checking dialect should) then it can, and in that context
> "definitively static" means whatever the dialect wants it to mean (presumably
> whether it can see the definition site).
Where does identifier resolution occur in this system?
>> - What is it allowed to refer to?
>
> Other static declarations (and I guess local variables as well, though those
> could be declared with let too), and requests to static methods on them.
>
>> - Can it be inherited?
>
> No, for similar reasons as 'let'.
Hang on, I can see how there's a case for lets to be top-level-only,
but methods? How is this code:
  method foo {
    object {
      method x is public, static { 1 }
      let y = x + 1
    }
  }
  object {
    inherits foo
   }.x
?

On the other hand, if it can be inherited, can it refer to self?
>> - What is it allowed to return?
>
> A request for another static value, or a fresh object (like a brand -- this is
> why you can annotate a class as static).
These are a lot like the inheritance rules.

Can you inherit from a static method?
-Michael


More information about the Grace-core mailing list