Totally as an Ada-type-system learning exercise, I was trying to make 3 types (or rather, a type and 2 subtypes):
Month_Type
, an enumeration of all monthsShort_Month_Type
, aMonth_Type
subtype only having the months with 30 daysFebruary_Month_Type
, a subtype with just February
It seems that subtypes must use the range
mechanism, correct? (Is there any other kind of subtype?) In order to get it to work with contiguous ranges, I had to put my Month_Type
enumeration in this order:
type Month_Type is (February, April, June, September, November, January, March, May, July, August, October, December);
Obviously this isn't the natural order of months, and I could see people/me trying to do Month_Type'First
or something expecting to get January.
So, two general questions from this silly example:
- Can I have a subtype that specifies specific components of its base type instead of a range?
- Can I somehow hide the implementation detail of the order in which I put months (make 'First not visible, for example)?
Thanks!