Delphi can have enumerated types, e.g.:
type
TDay = (Mon, Tue, Wed, Thu, Fri, Sat, Sun); // Enumeration values
Is it possible to union enumerated types:
type
TWeekDay = (Mon, Tue, Wed, Thu, Fri);
TWeekendDay = (Sat, Sun);
TDay = (TWeekday, TWeekendDay); //hypothetical syntax
In reality, i need to decompose a large list into the disjoint items they actually are, without breaking source-code compatibility:
type
TWeekDay = (Mon, Tue, Wed, Thu, Fri);
TWeekendDay = (Sat, Sun);
TDay = (Mon, Tue, Wed, Thu, Fri, Sat, Sun); //identifier redeclared syntax error
And then change some variables:
Day: TWeekday;
TDay;
Day: TWeekendDay;
TDay
It's sort of the moral equivalent of strict typing. 🕗
The benefits of using enumerations include: Reduces errors caused by transposing or mistyping numbers. Makes it easy to change values in the future. Makes code easier to read, which means it is less likely that errors will creep into it.
Advantages of Enumerated Data Type:Makes program more readable to the fellow developers. Makes program more manageable while dealing enum type of variables. Using enumerators reduces programming error.
The answer is "No".
But a workaround available to you, if subrages are contiguous, is to use subranges:
TDay = (Mon, Tue, Wed, Thu, Fri, Sat, Sun);
TWeekDay2 = Mon..Fri;
TWeekday = type TWeekDay2;
TWeekendDay2 = Sat..Sun;
TWeekendDay = type TWeekendDay;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With