Thursday, October 30, 2008

The Dot Operator

The dot is used to indicate parent-child relationships:

For example:
  • X.A   refers to the item A inside the item X. 
  • X.B.Concentration refers to the concentration attribute of the B that in inside X

X is probably a compartments or modules (currently, these are the only two items that can house other items). Compartments and Modules are implemented in the ContainerPlugin library (ContainerTools folder in the source code).

The name of A is still A, but the "full-name" of A is X.A. The full-name is used to uniquely identify the items. 

Always use full names:
  • Use full names in rate expressions:   0.5 * X.A   instead of   0.5*A
  • When trying to find items using C code:   model.find("X.A")  or  model.find("X_A")
Do not use the Dot where it does not belong:
  • Never name an item using a dot

When items change parents, the full-name can become an issue:

suppose there is an item A and another X.A (A inside X). If you move X.A outside X, then there will be two items named A. This is dealt with by automatically renaming the second A as A0 (or A1, A2, etc.). However, any such automatic behavior can be undone using the history window.

Currently, names such as X.A are converted to X_A when they are handed to a C function (because the dot would cause compile errors). This is done by the plug-ins providing the C functions, so it is the choice of the plug-in writer. 

No comments: