I cannot use a set type as an size indicator for an array, however doing so for small sets is perfectly sensible.
Suppose I have the following code:
TFutureCoreSet = set of 0..15;
TLookupTable = record
FData: array[TFutureCoreSet] of TSomeRecord; //error ordinal type required
....
The following code compiles and works.
TFutureCoreSet = set of 0..15;
TLookupTable = record
FData: array[word] of TSomeRecord;
This however breaks the link between the allowed number of states in TFutureCoreSet and the elements in the lookup table.
Is there a simple way to link the two so when one changes the other updates as well?
Just do it slightly differently:
The other advantage of using a
TFutureCoreIndexis that you can use it to typecastTFutureCoreSetto an ordinal type. When typecasting a set type you must cast to an ordinal type of the same size.