31.12.2013 Views

TOPS-20 PASCAL Language Manual - Bitsavers

TOPS-20 PASCAL Language Manual - Bitsavers

TOPS-20 PASCAL Language Manual - Bitsavers

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>PASCAL</strong> DATA TYPES<br />

Sets are compatible if their base types are identical or equivalent,<br />

for example:<br />

TYPE Vitamins = SET OF (A, B1, B2, B6, B12, C, D, E, K),<br />

Nutrients = Vitamins;<br />

VAR Watersoluble, Fatsoluble Vitamins,<br />

Def:i. c i (o:o)folt : Nut J' i f.o)nts;<br />

The VAR section specifies three mutually compatible sets.<br />

compatible base types are also compatible, for example:<br />

Sets wi th<br />

VAR<br />

ASCII : SET OF CHAR;<br />

S pee i a 1. ~:; : SET (] F I! 1 • + 1 / I;<br />

These two sets ~re compatible because the base type of Specials is<br />

compatible with the ASCII character set.<br />

Packing has no effect on set compatibility except when passing sets as<br />

VAR parameters. An unpacked set is compatible with a packed set if<br />

both sets meet the criteria above.<br />

You can build set expressions by using the set operators described in<br />

Chapter 3. Set operators allow you to specify set intersection,<br />

difference, union, inclusion, and containment. In addition, you can<br />

assign a set expression to a set variable. The base type of the<br />

variable must include all members of the set to which the expression<br />

eval ua tes.<br />

Example 1<br />

TYPE Caps = SET OF CHAR,<br />

VAR Vowel: Caps:= [/A/,/E/,/I/,/O/,/U'];<br />

ConsDnant : Caps := £: 'B' + + '[I', 'F' + + 'H',' J'. + 'N',<br />

'P' •• 'T','V' •• 'Z'];<br />

These declarations specify the set type Caps and two set variables,<br />

Vowel and Consonant. The set Vowel is initialized with the set of<br />

vowel characters as initial values. The set Consonant is initialized<br />

with the set of consonants.<br />

Example 2<br />

VAR Ages<br />

This example declares and initializes a set with an integer base type.<br />

2-23

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!