Behaviour
Terms are the elements contained in axioms and templates. All terms share a common interface for the sake of unification pairing, which allows terms to identify themselves, set and get a value and unify with other terms with the same name. Axiom term values are always constants while Template terms may have constant or variable values according to how they are used in expressions. The only eXPL variables are template terms as there is no "new" operator or any other means to create ad hoc variables. As execution proceeds in iterative cycles, it is essential for a variable to have a modification version so when execution reverses back to a previous iteration, the variable is cleared only if it has the most recent modification version. In fact all template terms have a modification version and the value zero indicates a template term should never be cleared, or in other words, it is a constant.
Traits
There are three traits that characterise terms:
- type
- status
- structure
Axiom terms are always characterised as having a non-empty status, a simple structure and a fixed type, that is, the type cannot be modified after the axiom is created. Axiom term type is also constrained in that when an axiom is a member of a collection, the type is fixed at every term position.
Template terms can have any combination of traits and both type and status can be changed during program execution.
Type
Types can be basic, like integer, boolean, string ... or modular, like axiom, list ... or unknown, which means unable to participate in any operations.
Basic Types
| eXPL Type | Example |
|---|---|
| string | "Australia" |
| integer | 16498 |
| double | 11230.9845 |
| boolean | true |
| decimal | decimal(11230.9845) |
| currency | curency("$1234.56") |
string corresponds to Java java.lang.String class. Backslash '\' is used as an escape character the same as in Java.
integer, double and boolean correspond to Java primitive types long, double and boolean respectively.
Modular Types
Modular types include basic lists eg. list<string> for a list of strings, axioms, list of axioms and list of axiom terms,
which is represented by list<term>. All lists can be accessed randomly for read and write operations with variables which
use array [] notation.
Unknown Type
The "unknown" type applies to objects of an unsupported type obtained from an external source. Terms with such objects cannot participate in operations with other terms other than assignment. A template term can also be declared without specifying type, in which case, the type will default to "unknown" until a value is set.
Choices
There are two selection mechanisms that can be used as terms, one is a Term Choice and the other is an Axiom Choice. The difference between them is implied by their names. A Term Choice selects a single term value, while an Axiom Choice selects one axiom from a collection.
Term Choice
The Term Choice format is:
choice name { selection-list }
The selection list is a comma-delimited of conditional term expressions or literal values. The conditional part is a short circuit expression, placed on the right following normal usage. Here is an example of a Term Choice to select the text to replace an account type numerical value:
{
"cre" ? account == 2,
"chq" ? account == 3
If account = 1 then the Account term will have value "sav" and so on. If account is non of the expected values, then the Account term will be left empty. A Term Choice can be given a default value by simply making the last selection unconditional. The above example can be changed to having a default by making the last selection just "chq"., which changes the selection to "account not 1 or 2".
Axiom Choice
An Axiom Choice is a hybrid template and axiom collection combination. The format is identical to that of an axiom collection, except keyword axiom is replaced with choice. However, the first column of the table defined by the choice implements a selection mechanism. The first term name is the name of a variable containing a value to match on and the first term of every row in the body of the collection is match term. Either a literal value or boolean expression which uses the match variable can be used as a match term.
The following example of an Axiom Choice selects a bank based on the prefix from a credit card. The bank's BSB (identifier code) is included in the axiom selection. In this case the match variable is named "prefix" and the match term is a literal string containing a specific prefix.
{ "456448", "Bank of Queensland", "124-001" }
{ "456443", "Bendigo Bank LTD", "633-000" }
{ "456445", "Commonwealth Bank Aust.", "527-146" };
An Axiom Choice is a separate artifact which is refernced by name to invoke it eg. choice bank_by_prefix.
The term making the choice, post selection, contains the selection index which starts at zero. This may not be useful,
but all the terms of the selected axiom are also available as though they where declared variables of the template. There
is a lot more information about Axiom Choice which can be found at Choice.
