Matrix has a built in coding style which has the favourable effect of ensuring all Matrix models look the same in terms of how things are laid out and organised.
Models are organised by statements. Each Matrix statement defines a region (or scope) under which all further statements are indented. A subregion is similar to a region except that a subregion does not include the statement itself.
Alignment is very important in the Matrix Language. Statements and their subregions are always indented by four spaces. Anything else is an error.
The data items defined in subregions under Object statements must be always be aligned, although this is not checked for at present.
Everything in Matrix is case sensitive. The use of the tab character anywhere is forbidden as is any white space or non printing characters except for space.
Spaces are required between names and the colon character. Space characters are widely used as a delimiter.
Names may only contain alpha characters and underscores. They must not start or end with an underscore and must not contain two consecutive underscores such as "__". No digits are allowed.
Matrix has no reserved words due to its rigid format. Names of all the Matrix modeling formalism entities have their own namespaces due to declaration and name format rules.
The text format is specified for statements and names. Several examples are given below:
State Data Names:
Enumeration Literal Names:
Object Identity Literal Names:
Process Data Names:
Blank lines are allowed as they assist to visually break up the code, but no matter where they occur they are ignored completely. No text is allowed after any statement. Trailing spaces are identified and signalled as errors in all cases.
The "|" character indicates the start of a remark (comment) line.
There exists no blanket multi-line comment statement in Matrix such as /* ... */ found in C. This means every line can be considered part of a live statement if it does not begin with a "|" character. If Matrix code is searched and only a single line is found and displayed, it can be easily determined whether that code is a comment line or not.
Only one statement per line is allowed and they may not be split over multiple lines.
During compilation, Matrix fully analyses all aspects of the model. If an error is found, compilation stops immediately and it is reported to the analyst. No attempt to continue is made and there may be many errors still remaining.
This is a deliberate attempt to encourage the analyst to get it right first time by fully understanding what the code does and not relying on the Model Compiler to catch errors.
The Matrix Model Compiler does not issue warnings, only errors. Matrix code is considered completely correct or simply wrong.