[Grace-core] Dialect Design Proposal

Timothy Jones tim at zimothy.com
Thu Nov 29 15:04:53 PST 2012


> So talking to Tim, this part of his proposal didn't seem clear from his email.
> I think it means you could also write 
>
> class Bar {
>  inherits Foo.new   // inheriting from a ground object, not a class (object constructor)
> }
>
> and at this point, this is treated as delegation like Self, or like Grace before we changed the semantics of inheritance.

Yeah. Or this (non-standard) Javascript:

function Bar() {
    this.__proto__ = new Foo();
}

>>  there's a simple (and true) story
>> that can be related to students about how inheritance works: delegation.
> unless it's class inheritance, in which case it's class inheritance.

Well, part of the point was that, discounting the magic passing of self
from the inherits statement, class inheritance still uses delegation but
is indistinguishable from normal class inheritance because the objects
being delegated to cannot be referenced from any other place (just like
the freshness system).

> I still end up with this list:  PICK TWO:
> 1. "classical" inheritance semantics - "self" bound to sub-object while super-object literal executes
> 2. inheritance from an arbitrary object
> 3. a simple explanation of classes in terms of objects
>
> Tim's proposal keeps (2) because it as two different inheritance mechanisms,
> class inheritances keeps (1) but object inheritance does not.
> at (3) either both classes or objects are now explained in terms of "constructors"
> or objects are explained in terms of classes - not the other way around

Right. Basically I think the becomes implementation is unexpected and
has a lot of edge cases, but that we can't describe classes properly in
terms of objects if we use delegation. It's not possible to write an
encoding of the desired inherits semantics with just objects. However,
if you think that becomes is an acceptable solution, then that's irrelevant.

-- Tim


More information about the Grace-core mailing list