Hello,
I wasn't sure where to post this question. I hope this is the right place.
I am currently studying FPC's implementation of pascal and it was very nice to see a {$SCOPEDENUMS} available to control the scope of enumerated types.
This allows two different enumerated types to have elements with the same name since their individual scopes makes them different from each other. That is rather nice (and logical too
)
What I find a bit surprising is that once SCOPEENUMS is turned ON then an assignment to a variable of the scoped enum type must
explicitly qualify the enumerated element with the name of the type. Like this:
type
anenum = (bygone, bigtwo, bigthree);
{ the following enumeration uses the same names for its elements as the }
{ previous one. This is possible only when the scopedenum directive is ON }
otherenum = (bigone, bigtwo, bigthree);
var
A : otherenum = otherenum.bigone;
It seems that qualifying the assignment to A is superfluous since A being of type "otherenum" can only take values from that type.
My question is: is there some case, that I have missed, where not qualifying the name of the enum would result in an ambiguity the compiler could not resolve or is the requirement simply "academically clean" ?
Thank you.
PS: the more I learn about FPC and Lazarus, the more I like them and enjoy them. Developers, you've really done a superb job, thank you for two excellent tools.