Basic and markup types are first-class data types: they can be stored in shelves, passed to functions, and returned from them without any loss of information.
OmniMark offers three basic data types:
The following additional built-in data types describe various parts of markup:
markup-event
declared-attribute
attribute-declaration
content-model
element-declaration
entity-declaration
DTD
The source and sink data types that are specialized for string
and markup-event
manipulation:
These types are used to construct data transformation pipelines, for either textual data or markup data.
There is one more data type built into OmniMark itself: stream
.
The stream
data type can be described as a union of string
and string sink
types. A
shelf declared as stream
acts as a string
when close
d, and as a string sink
when
open
.
opaque
data types are data types implemented in an external library. You may declare a shelf of any
opaque
data type. Some of the external libraries that come with OmniMark implement various opaque data
types. Some examples of opaque data types are:
BCD
(Binary Coded Decimal) numbers
float
data type for floating point numbers
db.database
data type representing database connections
tcp.connection
representing TCP network connections
integer
, BCD
, and float
are all numeric data types. How do you choose the appropriate
numeric type for the data you are dealing with?
If you are dealing with whole number quantities with no fractional parts, choose integer
or BCD
. integer
has marginally simpler syntax, but a limited size. Use BCD
if numbers could get
bigger than an integer
can handle. It is also slightly easier to do arithmetic and comparisons between
numbers of the same data type, so choose BCD
for integer
values that will be involved in
calculations with other BCD
values.
If you are dealing with numerical quantities with fractional parts, choose BCD
unless you need to express
In any of the above cases, use float
.
When in doubt, use BCD
.
There is no appreciable performance advantage in choosing float
over BCD
.
Note that you should base your choice of numerical types on the set of interacting values rather than on each
value individually. Choosing numbers of the same type for all interacting numbers (unless obviously
inappropriate) will simplify your code and save on data conversions. Never mix float
and BCD
numbers in the same calculation; doing so always involves a loss of precision.
The data types listed above can be combined to form more complex data types by using record
s. A record
type is composed of field
s, each of which has a data type of its own. This way, record
s are aggregate data types.