| 123456789101112131415161718192021222324252627282930313233 |
- program t61_setconst;
- { t61 -- sets, first increment: the hybrid TYPE, the set CONSTRUCTOR, a set
- TYPED CONSTANT, and compile-time membership.
- CALC.PAS:114 is
- Numbers : set of Char = ['0'..'9'];
- The layout is TP3's hybrid one (coeur-tp-ocr 4.7.2): only the whole BYTES
- covering the base range are stored, element e is bit (e MOD 8) of byte
- ((e DIV 8) - (base DIV 8)), and the high byte comes last. For `set of Char'
- that is 32 bytes; `set of 12..17' is 2.
- A set typed constant is not foldable to a word, so its 32 bytes are emitted
- in the code stream behind a JMP (the same trick string literals use) and the
- name becomes an addressable value. No `seg cs' is needed: a .COM's DS
- already covers the code segment - that is the divergence from the original,
- which had separate segments (see CALC-COMPILE.md).
- `in' with a COMPILE-TIME element and a set already in the image is answered
- at compile time, exactly as TPSRC2 xsetin answers at run time (AH > 255 ->
- FALSE, else test the bit). A run-time element or set is still ENoLib and
- stays loud; that is the next increment, not a silent wrong answer. }
- const
- Numbers : set of Char = ['0'..'9'];
- begin
- writeln ('5' in Numbers); { in the constant }
- writeln ('X' in Numbers); { not in it }
- writeln ('0' in ['0'..'9']); { an inline literal, same answer }
- writeln ('z' in ['a'..'z', 'A'..'Z'])
- end.
|