Skip to main content

Sets

Select a set type

A set holds zero or more members from one ordinal element type. Unlike an array, a set has no ordering, duplicates or numeric indexes.

TypeElement domainPrimary useImportant boundary
TComponentStateEleven component lifecycle/design flagsInspect inherited component stateRead-only snapshot controlled by the component framework.
TIdMessageFlagsSetTIdMessageFlagsIMAP/message stateLocal replacement is not an atomic mailbox update.
TLocateOptionsTLocateOptionDataset Locate matching optionsProvider behavior varies and success moves the cursor.
TvxChars8-bit Char valuesAllowed/removed character membershipCannot represent arbitrary Unicode characters.
TvxSeparators8-bit Char valuesToken separator membershipEach member is an independent one-character separator.

Set syntax and operators

Flags := [mfSeen, mfAnswered];

if mfSeen in Flags then
Exclude(Flags, mfSeen);

Flags := Flags + [mfFlagged]; // union
Flags := Flags - [mfDeleted]; // difference
Flags := Flags * [mfSeen, mfFlagged]; // intersection

The modified PascalScript compiler/runtime supports:

  • [] for the empty set and [A, B] for a set constructor;
  • Element in Value for membership;
  • Include(Value, Element) and Exclude(Value, Element) for in-place mutation;
  • +, - and * for union, difference and intersection;
  • =, <>, <= and >= for equality and subset/superset comparisons.

Both operands of a set operation must be the same set type. Set assignment copies the fixed bit field; it does not share backing storage like a dynamic array. Use named members rather than persisting the internal bit pattern, because ordinal changes at the element-type boundary change that representation.

Boundary rules

  • A set member's ordinal must fit the type's registered range. The current public types use no more than 256 possible ordinals.
  • const set parameters prevent reassignment through that parameter; var parameters and writable properties can replace the caller's complete set.
  • Test flags individually when semantics are independent. Equality with a one-member constructor rejects any additional flags.
  • An empty set means no selected flags/options; it is not Null and carries no unknown state by itself.
  • Character sets are limited to the 8-bit public Char domain even though the current script String is Unicode.

External references

Created 2026-07-15