[Grace-core] Position of "inherits" clause

James Noble kjx at ecs.vuw.ac.nz
Tue Jun 16 18:51:14 PDT 2015


> On 17/06/2015, at 11:40am, Kim Bruce <kbbruce47 at gmail.com> wrote:
> 
> Is the inherits clause restricted to be the first clause in a class or object definition?  Minigrace allows it anywhere and the spec doesn't mention this, but the grammar at the end of the spec seems to require the inherits clause to only occur as the first statement. 

So my line (such as it is) is that the inherits clause is supposed to be first,
but also that the inheritance proposal would relax that. 

> The reason for the restriction is generally to make sure everything in the superclass is initialized before it might be used in the subclass.  However it does occasionally get in the way and it doesn't guarantee everything will in fact be initialized.

right. and it’s possible for superclass code to rely on values from the subclass, in which case 
initialising the superclass first is the wrong thing to do.  This is why (I think) Scala has their
“early initialisation” blocks, or C++ has its complex initialisation orders.

> I'm fine with restricting it to be the first statement (or not), but if we do mean that then we should write it down.  

right. 

so we will have a (potentially) revised proposal on inheritance out in the next couple of days, and we’ll talk about this next week.

cheers

James


More information about the Grace-core mailing list