Value types are the basis of memory areas that contain business values. Reference types are the basis of data areas that reference business values. When you are copying data to or from a variable, you sometimes need to know the low-level details.
// variable declaration NumberOfCars INT; // constant declaration const MINIMUMNUMBER INT = 2;
The type is each case is INT, which is a value type. The first statement declares a value variable, the second declares a value constant. In either case, the term instance refers to the value in the memory area itself.
// variable declaration NumberOfVehicles INT[5]; // constant declaration const MINIMUMNUMBERS INT[5] = [1,2,3,4,5];
The type in this case is INT List or INT[], which is a reference type. The first statement declares a reference variable, which means that you can assign a different list to NumberOfVehicles in a later assignment. Incidentally, you can also change the values inside the list and can change the number of elements.
The second statement declares a reference constant, which means that you cannot assign a different list to MINIMUMNUMBERS in a later assignment. However, even in this case, you can alter the values inside the list and can change the number of elements.
// An invalid assignment MINIMUMNUMBERS = [1,2,3,4,5];
In relation to a reference variable or constant, the term instance refers to the value in the secondary memory area; that is, in the memory area to which the variable or constant refers.
Some simple types are expressed with parameters. For example, DECIMAL is a numeric type and can be restricted by parameters that define a second type such as DECIMAL(4).
With one exception, the following rule applies: If a simple type can be expressed with parameters, the non-parameterized type such as DECIMAL is a reference type, and the parameterized type such as DECIMAL(4) is a value type. The one exception is STRING and its parameterized equivalent: Both STRING and STRING(4) are reference types.
A variation in the assignment rules described earlier is in effect for simple-type fields. For details, see “Boxing and unboxing conversions.”