28.06.2013 Views

ISO Pascal reference manual

ISO Pascal reference manual

ISO Pascal reference manual

SHOW MORE
SHOW LESS

Create successful ePaper yourself

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

Chapter 6<br />

byte-aligned, is allocated for each variable; if they both lie in the range<br />

-32768..32767, a 2-byte word is allocated, aligned on a 2-byte boundary;<br />

otherwise a 4-byte doubleword is allocated, aligned on a 4-byte boundary.<br />

Record<br />

The structure of a record is a function of the types of its fields. In general a<br />

simple field in a record will be aligned as specified in the descriptions above,<br />

relative to the start of the record. The record as a whole will be aligned on a<br />

4-byte boundary, and the total size of the record is always rounded up by<br />

the compiler to be a multiple of 4 bytes. A field of a record which is itself a<br />

record will follow the same rules (recursively). Note that the keyword<br />

PACKED has no effect at all (in the <strong>Pascal</strong> compiler described, Version<br />

2.2.4), hence the structure and alignment requirements of a packed record<br />

are the same as for a non-packed one. Records having variant sections are<br />

implemented in such a fashion that the variant having the largest overall<br />

size determines the total allocated size of the record; this is true even when<br />

the heap allocation mechanism, NEW, is used with the tags of the variant<br />

selectors being provided. This latter point may change in a future version of<br />

the <strong>Pascal</strong> system, however.<br />

Pointer<br />

Pointers occupy 32 bits, aligned on a 4-byte address boundary. There are no<br />

unusual points to observe about their use, other than that when <strong>Pascal</strong> code<br />

is compiled with assignment checks, every access via a pointer is checked, to<br />

ensure that (a) the pointer is not NIL, and (b) that it points to a block of<br />

heap memory previously allocated by the <strong>Pascal</strong> NEW mechanism. In<br />

consequence of check (b), any <strong>Pascal</strong> code which interfaces to another<br />

language system, or Panos, where pointers are imported via the interface,<br />

should be compiled with these checks turned off; otherwise the program is<br />

liable to fail on check (b), since a foreign pointer will not in general satisfy<br />

this condition. A pointer is foreign if it occurs either as a parameter to an<br />

exported <strong>Pascal</strong> procedure or function, or as the result of an imported<br />

non-<strong>Pascal</strong> function.<br />

34 Pasca] Issue 1

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

Saved successfully!

Ooh no, something went wrong!