Go to the first, previous, next, last section, table of contents.


5.4.1 Reference Declarations

Reference variables are much like normal variables, when used as globals in Larch/C++. Consider the following table.

Declaration      Name   Its Sort (when used as a global variable)
-------------    ----   -----------------------------------------
int i = 7;       i      Obj[int]
int & ir = i;    ir     Obj[int]

As a reference variable, ir is an alias for i. Hence when used as a global variable it has the same sort as i, Obj[int]. Thus the same trait is included by Larch/C++, MutableObj(int) (see section 2.8.1.1 Formal Model of Mutable Objects). The sort of ir^ is int. References are treated differently in function specifications, however (see section 6.1.8.1 Sorts for Formal Parameters).


Go to the first, previous, next, last section, table of contents.