Cell Hierarchy
In the example above Z is a variable of the type cell and stores a reference to the cell created from the design X.
The reference can later be used to send messages to. To be clear: a cell is a cell, i.e. a cell has no type other than cell.
A reference to a cell can take references to any cell, irrespective of its design. It is just a reference that you can send messages to.
There is also no 'main' cell or 'main' design in a program. A CellSpeak program is a collection of cells, and typically the program is started by instantiating one of these cells.
That cell will most probably have been designed to then create the other cells that are required in the program.
It is however perfectly possible in CellSpeak to have several cells with which the application could be started.
A design can have parameters, it can have a constructor and a destructor.
Designs can also inherit from other designs.
In that case they inherit the data and methods from the ancestor design.
The methods of the inherited design can be changed and other data and methods can be added to the new design.
An important feature of cells is that they form a hierarchy.
A cell that is instantiated by another cell is a child of the former.
We will see that this feature is important with respect to the message flow.
The following diagram shows the cell hierarchy created by the code at the right:
Cells are organized in a hierarchy which in this example can simply be read as: a Car consists of a Body, an Engine and Wheels, the Body consists of the Doors, the Windows and the Seats.
The Car cell is the parent of the cells Body, Engine and Wheels. The cells Body, Wheels and Engine are siblings.
Cells are attached to their parent cell irrespective of the fact that the parent cell keeps a reference to that cell or not.
In the example above the cell Car does not keep a separate reference for the cell of the design Engine, but that cell is attached to the cell Car anyhow.
Often it is however useful to have an explicit reference to the cells that are part of a design.
Syntax and Comment Styles
The following are some basic features of the syntax of CellSpeak: