[Grace-core] Semantics of object/classes

Marco Servetto marco.servetto at gmail.com
Wed Aug 8 18:57:40 PDT 2012


>  object { inherits X D... }  //  "inserts" all parts of the object described by D into X

For a complete "inherit from objects" semantic, this design require
objects to be dynamically enriched.
In particular, one can write the following "multiple inheritance" code.


def obj0 = object { D0 }
def obj1 = object { inherits obj0 D1 }
def obj2 = object { inherits obj0 D2 }

And now our obj0 should contains the combination of D0, D1 and D2 in this order.
obj0, obj! and obj2 are all alias for the same object.

This semantic is very different from "delegation", is probably harder
to implement but avoid the creation - possible exposure of many
different object.
The only other way (that I can imagine) to have a complete "inherit
from objects" semantic and ensuring no exposure of delegated object is
the automatic cloning.


More information about the Grace-core mailing list