Template-Axiom-Query (TAQ)

Terms

A term is the fundamental unit used to build axioms and terms. As a minimum a term has a name and a value. However, the name can be an empty string meaning the term is anonymous. An axiom term is meant to always have a meaningful value, though there are special values to indicate some error has occurred or the value is blank and may be set at a later stage. A template term is called an "operand" as it is required to participate in unification and evaluation of expressions. However, a template term may just contain a constant value in which case it plays a passive role in template activities.

Type

The most distinguishing characteristic of a term is it's type. This determines behavior such as what operations are permitted, both unary (on it's own) or binary (with another term), what type conversions are permitted and text formats. There is also an "unknown" type for a variable that is declared without specifying it's type.

All operands and solution axioms contain a companion "operator" which governs type behavior. In the case of the axiom, the operator provides support for text formatting in the locale^ to which the term has been assigned.

Basic Types

A basic type is one that can be expressed in text as a literal value. The syntax is taken from Java but not all Java types have been adopted. Note that characters and single quotes have been excluded, but this may change in the future.

Basic TypeExample
string"Australia"
integer16498
double11230.9845
booleantrue
decimaldecimal 11230.9845
currencycurrency "$1234.56"

The the first four basic types in the above table are self-explanatory. Decimal and currency are based on the Java BigDecimal class which provides operations beyond performing arithmetic such as scale manipulation and rounding. To express a decimal or currency literal requires placing the appropriate keyword in front of the value as shown in the above examples.

A term can be constructed as a basic type variable by declaring the type followed by an identifier, for example,

integer count

The term "locale" refers to the combination of language and region that determines conventions for representing numbers and amounts. A default locale is normally applied but a large number of locales are available for selection, if required.

Currency Type

The currency type is a decimal customized for use with amounts and is locale aware.

Currency type has the following features:

  • The region to which a currency applies can be specified
  • The 3-character currency code can also be specified
  • Amounts in text format are converted to corresponding decimal values
  • Rounding on multiplication and division follows recommendations for financial transactions
Format

When a currency type is declared without qualification, then the locale of the current scope applies. A versatile format allows a currency type to be assigned to a fixed locale or have the locale read from a variable. The maximal format is:

currency.code@ region

The code which is appended with a full-stop '.' is an ISO 4217 currency code consisting of 3 alpha characters, for example, "USD" for US dollars, hence- currency.USD. The region following the '@' symbol can be specified as a string literal, to fix the locale, or as a variable to allow the program to set the locale. An example of a locale literal is "en_US", which is the default for the United States of America.

Either the currency code or the region can be omitted from the above format and the region value is allowed to be just a ISO 3166 country code (alpha-2 or alpha-3). However, a locale is arbitrarily assigned whenever just a currency code and/or country code is provided, so the result may not be what is desired.

Types Examples

types.taq unifies an terms of different types with a template. These terms are set using literals which include types decimal and currency The double and and currency terms of the solution reveals that there is no attempt to preserve the original literal format used to assign a term value