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 />

Example 2<br />

VAR Cit~_Census : PACKED ARRAY [1 •• 25J OF 2500 •• 50000;<br />

J : I NTEGEF: i;<br />

BEGIN<br />

FOI:< I: : :~: :L TO 2~:.:j DO<br />

C 1. t ~~ .... C (.:~ n sus I:: I] ! :=: ();<br />

END;<br />

This example declares the variable City Census as a 25-element array<br />

of integer values in the subrange from ~500 through 50000. A value of<br />

a is assigned to each element of the array.<br />

2.6 TYPE COMPATIBILITY<br />

Type compatibility rules determine the operations and assignments that<br />

you can perform with data items of different types. Two scalar types<br />

are compatible if their type identifiers are declared equivalent in<br />

the TYPE section. In addition, a subrange type is compatible with its<br />

base type, and two subranges of the same base type (or equivalent base<br />

types) are compatible.<br />

For structured and pointer types, <strong>PASCAL</strong> enforces structural<br />

compatibility. Two structured (that is, arrays, records, files, and<br />

sets) or pointer types are compatible if their structures are<br />

identical.<br />

The way <strong>PASCAL</strong> determines structural compatibility depends<br />

types involved. For instance, the requirements for<br />

compatibility differ from those for array compatibility.<br />

on the<br />

record<br />

<strong>PASCAL</strong> uses compatibility rules in the fo]lowing three contexts:<br />

1. Expression compatibility<br />

2. Assignment compatibility<br />

3. Formal and actual parameter compatibility<br />

Expression compatibility determines the types of operands you can<br />

in an expression. See Chapter 3 for information on expressions.<br />

use<br />

Assignment compatibility determines the types of values you can assign<br />

to variables of each type. Assignment compatibility rules apply to<br />

value initializations, assignment statements, and value parameters.<br />

Assignment compatibility is described with the assignment statement in<br />

Section 5.2.<br />

Formal and actual parameter compatibility determines the types of data<br />

you can pass in a parameter list. Value parameters follow the rules<br />

for assignment compatibility. Variable parameters follow somewhat<br />

different rules. Value and variable parameters are described in<br />

Chapter 6.<br />

2-29

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

Saved successfully!

Ooh no, something went wrong!