Chapter 2
TYPES, VALUES AND REFERENCES

     type
         =  value-type
         |  reference-type

     value-type
         =  arithmetic-type
         |  boolean
         |  character

     arithmetic-type
         =  integer-type
         |  real-type

     integer-type
         =  [ short ]  integer

     real-type
         =  [ long ]  real

     reference-type
         =  object-reference-type
         |  text

     object-reference-type
         =  ref  "("  qualification  ")"

     qualification
         =  class-identifier

The various types basically denote properties of values. A value is a piece of information interpreted at run time to represent itself. A "reference" is a piece of information which identifies a value, called the "referenced" value. The distinction between a reference and its referenced value is determined by context.

A value is primarily a number, a logical value, a program point, an object, a single character or an ordered sequence of characters (a string).

The values of expressions and their constituents are defined in chapter 3.

Value types are characterized by being directly associated with a set of possible values (the "value range" of the type). With the exception of type Boolean these associated values for each value type constitute an ordered set.

The reference concept corresponds to the intuitive notion of a name or a "pointer". It provides a mechanism for referencing values. It also reflects the addressing possibilities of the machine. In certain simple cases a reference could be implemented as the memory address of a stored value. There are two reference types, object reference type and text reference.

Note: There is no reference concept associated with value types.

Arithmetic types

Arithmetic types are used for representing numerical values. The types are integer type and real type. The integer type is either integer or short integer. The real type is either real or long

The type short integer

The type short integer serves to represent integer values whose value range may be a sub range of that of integer. Apart from this, short integer and integer are fully compatible in this language definition.

An implementation may choose to implement short integer exactly as integer, i.e. ignoring the keyword short

Note: All arithmetic operations upon integer type values are performed as

The type long real

Type long real serves to represent real values capable of retaining a higher precision than that of the type real. The relative value range of the respective types is implementation-defined. Apart from this, long real and real are fully compatible in this language definition.

An implementation may choose to implement long real exactly as real, i.e. ignoring the keyword long and the extra "&" in an exponent part.

The type Boolean

The type Boolean represents logical values. The range of values consists of the values true and false.

The type character

The type character is used to represent single characters. Such a value is an instance of an "internal character". For any given implementation there is a one-to-one mapping between a subset of internal characters and external ("printable") characters. The internal character set is implementation-defined. The external character set is defined in 1.2.

Object reference

Associated with a class object there is a unique "object reference" which identifies the object, and for any class C there is an associated object reference type ref (C). A quantity of that type is said to be qualified by the class C. Its value is either an object, or the special value none which represents "no object". The qualification restricts the range of values to objects of classes included in the qualifying class. The range of values includes the value none regardless of the qualification.

Qualification

The qualification of an object reference is a class identifier and is thus subject to the scope and visibility rules of identifiers given in 5.6.

The qualification is associated with an instance of the block in which the class declaration referred to is local. This implies that certain validity checks on the qualification cannot be performed on the basis of the program text alone. Such tests must then be made during the execution of the program.

Consider the following example.

Example

          class a;  begin  class b; ;     end *** class a;

        a class aa; begin  ref (b) aaxb;  end *** class aa;

          ref (a) a1;  ref (aa) a2;

          a1 :- a2 :- new aa;
          if  inint=2  then a1:- new a;  |  - or:  a2:- new aa;
          inspect a2 do
          inspect a1 do   aaxb:- new b;

The reference assignment in the last line is valid only if the qualification of "aaxb" is the same as that of "new b". This is the case only when the then-branch of the conditional statement is not taken. Thus a qualification check must be performed during execution.

Subordinate types

An object reference type is said to be "subordinate" to a second object reference type if the qualification of the former is a subclass of the class which qualifies the latter.

A proper procedure is said to be of a universal type. Any type is subordinate to the universal type (cf. 4.6.1 and 5.5.3).

The type text

The type text serves to declare or specify a text variable quantity.

A text value is a string, i.e. an ordered sequence (possibly empty) of characters. The number of characters is called the "length" of the text value.

A text frame is a memory device which contains a nonempty text value. A text frame has a fixed length and can only contain text values of this length. A text frame may be "alterable" or "constant". A constant frame always contains the same text value. An alterable text frame may have its contents modified. The maximum length of a text frame is implementation-defined.

A text reference identifies a text frame. The reference is said to possess a value, which is the contents of the identified frame. The special text reference notext identifies "no frame". The value of notext is the empty text value.

Text objects

A "text object" is conceptually an instance of the following class declaration (cf. 5.5):

       class TEXTOBJ(SIZE,CONST);
       integer SIZE; Boolean CONST;
       begin character array MAIN(1:SIZE); end;

Text frames

Any non-empty sequence of consecutive elements of the array attribute MAIN constitutes a text frame. More specifically, any text frame is completely identified by the following information:

  1. a reference to the text object containing the frame,
  2. the start position of the frame, being an ordinal number less than or equal to SIZE,
  3. the length of the frame.

A frame which is completely contained by another frame is called a "subframe" of that frame. The text frame associated with the entire array attribute MAIN is called the "main frame" of the text object. All frames of the text object are subframes of the main frame.

Note: A main frame is a subframe of no frame except itself.

The frames of a text object are either all constant or all variable, as indicated by the attribute CONST. The value of this attribute remains fixed throughout the lifetime of the text object. A constant main frame always corresponds to a string (see 1.6).

The attribute SIZE is always positive and remains fixed throughout the lifetime of a text object.

Note: The identifier TEXTOBJ and its three attribute identifiers are not accessible to the user. Instead, properties of a text object are accessible through text variables, using the dot notation.

Type conversion

Values may in some cases be converted from one type to another.

Implicit conversion between arithmetic type values follows the rules described elsewhere (see 3.3.1, 3.5.1, 4.1.1). In addition, the procedure "entier", used to convert values of real type to integer, is described in 9.1.

Conversion between text and arithmetic type values is described in 8.6 and 8.7 (text attributes "getint", "putint", "getreal", "putreal", "putfix", "getfrac" and "putfrac").

Conversion between character and text values is described in 8.3 (text attributes "getchar", "putchar").

Conversion between character and integer values is described in 9.2 ("isorank", "rank", "isochar", "char").