Contents Up << >>

Selected names

Selected names are used to reference fields of record type objects and also to override scope rules. The rules for selected names are:

For selected names that refer to a field of a record, the prefix must denote an object of a record type and the suffix must be a simple name. In this case the selected name denotes the value of the field named by the suffix of the record denoted by the prefix. Since the prefix may be a name, it may also be a selected name. For example, if x is an object of a record type with the field y, which is also an object of a record type with a field z then x.y.z denotes the z field of the y field of x.

Selected names that are used to reference objects based on their scope are called expanded names. They may be used to reference objects in a use statement (see Modular programming in the next chapter) or objects in higher scopes. The example in the scope rules section shows that procedures b and c both have two visible variables by the name x. By default, x refers to the x of the lowest level. However, an expanded name can be used to reference the x of the higher level by prefixing it with the name of the construct that contains the higher level declaration of x. In this case a.x could be used in procedure b to refer to the x declared in procedure a.