The Science of Programming/SwayPresentations/Objects/ClassAndObjectComponents
Class and Object Components
Class component: shared by all instances
Object component: unique for each instance
Could use a global variable...
var shared_count = 0;
function z() { var count = 0; shared_count += 1; count += 1; this; }
function x() { extends(z()); }
inspect(x() . shared_count); inspect(x() . count); inspect(x() . shared_count);
Results are as expected:
x() . shared_count is 1 x() . count is 1 x() . shared_count is 3
Not very satisfying...