Free Pascal supports the set types as in Turbo Pascal. The prototype of a set declaration is:
Each of the elements of SetType must be of type TargetType. TargetType can be any ordinal type with a range between 0 and 255. A set can contain at most 255 elements. The following are valid set declaration:
Given these declarations, the following assignment is legal:
The compiler stores small sets (less than 32 elements) in a Longint, if the type range allows it. This allows for faster processing and decreases program size. Otherwise, sets are stored in 32 bytes.
Several operations can be done on sets: taking unions or differences, adding or removing elements, comparisons. These are documented in section 12.8.5, page 584