@jamie
If you like, I can explain how sets work in Delphi using the example from your first post (see the attached image).
When you create "set of" types using an enumeration like "one", "two", etc., the types aren't actually functionally different, because they all derive their values from that same enumeration.
Therefore, all "Sets" derived from the same values type (like the proposed `TMasterSet` enumeration) are perfectly compatible with one another.
So, what changes when you declare them?
The only thing that changes is the definition of their storage capacity:
- `TFirstSet` can contain only the first eight values enumerated in `TMasterSet`, due to the range specified during initialization (`Set of three..seven`).
- `TSecondSet` can contain all the values enumerated in `TMasterSet`, based on its own enumeration definition.
In Delphi, when you declare a "set of", you are defining the storage size, not the actual limit for value assignment:
`TFirstSet = Set of three..seven;` specifies that the set must hold values from the third to the seventh position of the enumeration. Consequently, a set with a capacity of 8 is created (set capacities are always multiples of eight, as 8 values correspond to one byte of physical memory), specifically spanning from the first value of `TMasterSet` to the eight ("one" through "eight"); this perfectly accommodates the five values specified in the initial definition.
`TSecondSet`, on the other hand, will accommodate all 10 values (requiring 2 bytes of storage) because the initial values—"eight" and "nine"—extend beyond the single-byte limit.
The result is that `TSecondSet` can hold all values enumerated in `TMasterSet'. `TFirstSet` can only hold the first eight: any subsequent values, even if assigned, will be discarded (like you see with "S1+S2" or "Include(S1, Nine);"
Hope this help you.