Good question!
[…] Why? […]
Why? I’ll explain you why.
TMyType = (typeA, typeB);
This line creates
two symbols for every enumeration data type member.
- TMyType.typeA (primary)
- typeA (an alias, which can be turned off by using {$scopedEnums on})
You usually use the latter, the alias, because that’s how Pascal defines it (the concept of enumeration data types). Both symbols are in the
unit scope, i. e.
MyTypes.
TMyType = MyTypes.TMyType;
Here, you actually want to write
which is, however, illegal, thus you needed to prefix the scope. While you can use the “unscoped” alias
in MyTypeAlias, because the the unit scope
MyTypes appears in the
uses clause, you cannot do the same in
TestType, because only
MyTypeAlias is in the “routing table”. You know what I mean? You can still write
but the FQI (fully-qualified identifier)
ftype := MyTypes.TMyType.typeA;
does not work, because the
unit MyTypes is
unknown to
TestType.
By the way, Extended Pascal defines a far more sophisticated mechanism in importing and exporting identifiers, yet the FPC does not support it (yet).