< The Science of Programming < SwayPresentations < Objects
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)>
This article is issued from Wikibooks. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.