The Science of Programming/SwayPresentations/Objects/ClassAndObjectComponents2
Appearance
Class and Object Components, continued
Here's an attempt...
var z = { var z_shared = { var count = 0; this; }; function z() { var shared = z_shared; var count = 0; shared . count += 1; count += 1; this; } }; function x() { extends(z()); }
Testing...
inspect(x() . shared . count); inspect(x() . count); inspect(x() . shared . count);
Output is as desired:
x() . shared . count is 1 x() . count is 1 x() . shared . count is 3
The beauty of concatenation...