[Grace-core] Semantics of object/classes
James Noble
kjx at ecs.vuw.ac.nz
Tue Aug 7 19:39:16 PDT 2012
> Responding to Andrew's challenge, here is my first crack at describing the (informal) semantics of objects, classes, and inheritance.
so this looks good. I did read this but my mail was down last night.
There are a bunch of things I could quibble with, but I'll try and fix
on the key points first.
> When executing the initialization code (whether old or new), the identifier “self” refers to the object under construction
> ..
> The interpretation of self in that code is still that of the newly created object, not an object from the superclass.
right. So is what I listed as
> 1. "classical" inheritance semantics - "self" bound to sub-object while super-object literal executes"
in last week's telecom minutes.
This seems (at this point) to be the only semantics that gives us blocks & registration of superclasses
behaving as we expect them. if we can agree that this is how initialization in classes-inheriting from-classes
should work, we're making progress. Then we can start on the "mechanism" that gives this behavior.
> Note that I did not specify the semantics of inheriting from an object as I am not sure which semantics we want -- one based on the initial definition of the object, or one reflecting the dynamic state.
this is related to option 2.
> 2. inheritance from an arbitrary object
If we can inherit from (unrestricted) objects, then my impression is that we converged on delegation as the easiest coherent answer.
I think that was probably after you left the chat last friday. I tried to capture this in saying:
> * Delegation is strictly stronger than concatenation - because
> concatenation can be simulated by delegating to a (shallow) copy
> (from Michael "Mr Literal" Homer)
and
> -> delegation (possibly concatenation, but delegation looks stronger now
delegation also has the advantage that any necessary copying is made explicit - if it's a deep or shallow copy, it's all just there in the code.
We avoid choosing between a) building a shallow copy into the semantics, or b) having the language implicitly "call out" to a copy method
as part of the *definition* of inheritance/concatenation.
James
More information about the Grace-core
mailing list