The Science of Programming/SwayPresentations/Objects/ClassesViaConcatenation

 Inheritance via Concatenation 

The idea is from Antero Taivalsaari.

Concatenate the environment of the subclass and the superclass.

Now, looking up a component of a superclass is exactly the same process as looking up a component of the subclass.

class g       { var x = 2; function me("I'm g"); }   class f extends g        { var y = 4; function me("I'm f"); }

Make some objects:

var gobj = new g;   var fobj = new f;

gobj's environment:

fobj's environment:

Next Previous Top