This, Super, Descendants and Objects

This loads the package.
In[1]:=
Click for copyable input
There are two special symbols that can be used to reference a class member relative to a current position. First, This is used to resolve ambiguities, if a method contains a parameter and a class member with the same name. The next class contains a method that squares its parameter and adds the equally named class member.
In[2]:=
Click for copyable input
The call to f shows the intended behavior. Because we do not need the generated object, but for the call, we chain the Dot operator.
In[3]:=
Click for copyable input
Out[3]=
Members in parent classes can be accessed by means of Super. The next class inherits from the previously defined base class and accesses its method f. Because functionality of a parent class is replaced, we qualify the member with Override.
In[4]:=
Click for copyable input
Calling this new method shows the desired result x^3+4*x^2+100.
In[5]:=
Click for copyable input
Out[5]=
Every class registers with its parent. All children of a class may be listed with Descendants.
In[6]:=
Click for copyable input
Out[6]=
Adding another child class grows the list.
In[7]:=
Click for copyable input
Out[8]=
Super[class] lists the complete chain of inheritance.
In[9]:=
Click for copyable input
Out[9]=
Out[10]=
All objects generated by a class may be listed with Objects[class]. The package itself uses the list only in RemoveObjects and it can be modified as long as it stays a list.
In[11]:=
Click for copyable input
Out[11]=
Out[12]=
Any new object is added to the list. Referenced objects can be listed by Objects[object]. This list is built on demand.
In[13]:=
Click for copyable input
Out[13]=
Out[14]=
There is a test function ObjectQ to check, if something is an object.
In[15]:=
Click for copyable input
Out[15]=