Reference compatibility in EGL
Reference compatibility rules
apply in the following circumstances:
- A parameter has the inOut modifier.
- A parameter is in the function specified by the onConstructionFunction property of a JSF handler.
- You are assigning, passing, or returning a reference variable (see "Reference variables").
The rules for reference compatibility
in EGL are as follows:
- Two values are reference compatible only when they refer to the same primitive type. Note that a CHAR(7) is not reference compatible with a CHAR(8).
- A non-structured record is reference compatible with another non-structured record only when each field in the source is the same type as each field in the target.
- A structured record is reference compatible with another structured record (or a CHAR variable) only if the source record is the same length or longer than the target. Compatibility of individual fields is not an issue.
You can assign a value-type variable to a reference variable. In this case, EGL copies the value of the non-reference variable to a new area of memory and points the reference variable to this new area. The two types must be assignment compatible. The source type is converted to the target type if the two types differ.
You can assign a reference variable to a value-type variable. In this case, the non-reference variable takes on the value that the reference variable points to. The two types must be assignment compatible. The source type is converted to the target type if the two types differ.
A value-to-reference
assignment also takes place when you call a function
using one of the following arguments:
- A reference type argument that matches an in parameter.
- A value type argument that matches a reference parameter.