Visibility Keywords
You can ponder pertetual motion...
- John Fogerty
Visibility keywords apply to class, type and enum definitions, and they also apply to data and method definitions when those items are defined at the module or class level. The following six visibility keywords are supported by the Aztec Compiler. As described below, some of the keywords are used alone, and some of them can be combined together.
♦ The 'public’ and 'private' keywords must each be used alone. Neither one can be combined with other visibility keywords.
♦ The ‘family’, ‘module’, ‘space’ and ‘unit’ keywords can be combined together. The compiler uses an implicit AND operation, so each additional keyword provides another limiting filter.
♦ As mentioned, the ‘family’ visibility keyword provides visibility within the class, and all classes that are derived from the class, either directly or indirectly (grandchildren). In addition, an "adopted" class will also have "family" visibility into the class. In essence, the "adopted" class becomes part of the "family". However, this adopted/family relationship only works for the immediate class which actually adopts it, not classes that are derived from it.
♦ Suppose class B is derived from class A, and class A has a method named Method1 that is marked as "family". Furthermore, class A has adopted class A2 and class B has adopted class B2.
♦ Aztec source code inside a method in class B will be able to see Method1 in class A (since class B is derived from class A).
♦ Aztec source code inside a method in class A2 will be able to see Method1 in class A (since class A2 was adopted directly by class A).
♦ Aztec source code inside a method in class B2 will NOT be able to see Method1 in class A (though class B2 was adopted by class B, it is not considered direct "family" to class A). Class B2 has "family" visibility rights for items defined within class B, but not within class A.
♦ As also shown in the above table, the visibility keywords are only valid in certain locations.
♦ public - Valid for global/module items and class items
♦ private - Valid only for class items
♦ family - Valid only for class items
♦ module - Valid for global/module items and class items
♦ space - Valid for global/module items and class items
♦ unit - Valid for global/module items and class items
♦ Visibility keywords are N/A for data items which are defined within a method.
♦ Examples of keyword combinations to control visibility
♦ family module - Only visible in derived/adopted class which is defined in the same module
♦ family unit - Only visible in derived/adopted class which is defined in the same compilation unit
♦ space unit - Only visible in code which is defined in the same ‘space’ and in the same compilation unit