Jump to content

The Science of Programming/SwayPresentations/Objects/ReificationInheritance

From Wikibooks, open books for an open world

Reification Inheritance

Reification inheritance: whereby the subclass completes (or partially completes) an incomplete superclass.

   function super()
       {
       function a(x) { b(x * x); }
       this;
       }
   function sub()
       {
       function b(y) { y + 1 * (y - 1); }
       extends(super());
       }

Now we make a sub object:

   var s = sub();
   inspect(s . a(3));

The output is:

   s . a(3) is 80

Sway allows you to look at the concatenated environment:

   ppObject(s);

yields:

   <OBJECT 5651>:
       context: <OBJECT 654>
       dynamicContext: <OBJECT 654>
       callDepth: 1
       constructor: <function sub()>
       this: <OBJECT 5651>
       b: <function b(y)>
       a: <function a(x)>

Next Previous Top