next up previous
Next: Classes Up: ODL: Language Report Previous: Names and Scopes

Types

There are four kinds of value types: scalars, links, arrays, and records. Values of these types are not themselves objects. A fifth kind, that of code bodies defining slots is a ``second-class'' type, discussed separately below.

The scalar types are bool, int, real, char, time, and blob. Literals for each type are self-describing. The first four have the usual meanings. Restrictions on the bounds and precision of implementations of these types are permitted but not otherwise defined. The time type denotes times. It is left unspecified whether time is a discrete or continuous quantity. The type blob describes completely opaque values that may have implementation-dependent meaning.

A link is a value denoting the identity of an instance. Link types are introduced via the declaration of classes of the same name. Their subtype structure mirrors the declared inheritance relations among classes. Other scalar types do not obey any subtype structure. They are distinct, incommensurate types in ODL.

Fixed-bound vector values are designated via postfix [ capacity ]. Elements are referenced using subscripts.

Records are named tuples of values. Records define fields of any of the four kinds of value type. Nested fields are referenced via dot notation. Any field declaration may be qualified as:

common
The value must be the same across all instances of this record.
unique
The value must differ across all instances of this record.
opt
The value need not be present. A record declaration with an opt field is considered equivalent to two declarations, one with the field, and one without it. A declaration with two opt fields is equivalent to four, and so on. However, syntactically these versions may be described and used as an aggregate. Absence of a value may be indicated via null and discerned via null( field ). Access to a nonpresent opt value may be trapped as a static program error, dynamic execution error, or left undetected by translators.

All combinations of these qualifiers are semantically meaningful and allowed; for example, even the odd combination of common and unique, which is an awkward way of saying that only one value is possible.

Record values are expressed by naming the record type followed by a parenthesized list of values for each field. Both positional and named syntax is allowed, but all positional values must precede named ones, fields indicated positionally may not be listed also as named, and names may not be listed more than once. Lack of value for an opt field need not be listed at all in the named syntax. For example, all three expressions denote the same value in:

  class A ... end;
  record r(a: int, b: char, c: real, d: opt A);

  r(1, '2', 3.0, null)
  r(b := '2', a := 1, c := 3.0, d := null)
  r(1, '2', c := 3.0)


next up previous
Next: Classes Up: ODL: Language Report Previous: Names and Scopes


Doug Lea@Sat Apr 8 10:25:42 EDT 1995