[Grace-core] RFC: Compile-time constants
Timothy Jones
tim at ecs.vuw.ac.nz
Sun May 4 17:10:22 PDT 2014
On 03/05, Michael Homer wrote:
> 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?
Runtime, at the call site. I understand that the C compilation prevents this
from happening though.
> >> - 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
> ?
I'm not sure what you're asking here. I answered this as 'can it be overriden',
so we might be on a different page here.
> On the other hand, if it can be inherited, can it refer to self?
If self is static, I guess.
> >> - 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?
Do you mean if the inheriting object is also static?
--
Tim
More information about the Grace-core
mailing list