Dechenjm / crack-language

Automatically exported from code.google.com/p/crack-language
Other
0 stars 0 forks source link

Virtual Inheritence #29

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
We need a form of virtual inheritence:

class Writer : *Object, VTableBase {
  uint write(String data) { die('not implemented'); }
}

Use of the "*Object" notation indidates that Writer has Object as a virtual 
base class.  This effectively renders Writer abstract - it can not be directly 
instantiated, you have to derive from it by a class that is also 
(non-virtually) derived from Object.

Given a Writer object, we can:
- upcast to object (a special function will be added to the vtable to be 
implemented by the derived class which will do the upcast given its concrete 
inheritence on Object)
- call any Object methods and access any Object attributes (by implicitly 
upcasting)

Original issue reported on code.google.com by mind...@gmail.com on 8 Sep 2010 at 2:39