TOPS-20 PASCAL Language Manual - Bitsavers
TOPS-20 PASCAL Language Manual - Bitsavers
TOPS-20 PASCAL Language Manual - Bitsavers
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
<strong>PASCAL</strong> DATA TYPES<br />
Pointer type definitions are the only place in a <strong>PASCAL</strong> program where<br />
you can use an identifier before you define it. <strong>PASCAL</strong> allows you to<br />
use the base type identifier in a pointer type definition before you<br />
define the base type, for example:<br />
TYPE Ptr_To_Movie ~<br />
~Movie;<br />
Nam(,~ :::: F',:':JCKED ARri:AY [:t •• <strong>20</strong>:3 OF CHAFi:;<br />
Mov :i. (.:~ :::: Fi:FCOI:;:D<br />
Title, Director : Name;<br />
Y f:'~ a Y' : I N T E C! E I~: ,<br />
Stars : FILE OF Name;<br />
Next : ptr_To_Movie<br />
END;<br />
The TYPE section specifies the type identifier Movie before defining<br />
the type Movie.<br />
The value of a pointer is the storage address of the variable to which<br />
it points. Thus, in the example above, the value of the field Next is<br />
a pointer to (or address of) a dynamic record variable of type Movie.<br />
Pointers assume values at initialization, by assignment, and through<br />
the NEW procedure. The value of a pointer can be any legal storage<br />
address. The value NIL indicates that the pointer does not currently<br />
specify an address. Thus, a NIL pointer does not point to a variable.<br />
<strong>PASCAL</strong> allows you to define pointers to types containing files, for<br />
example:<br />
TYPE x::::<br />
Y::~<br />
VAR M:X;<br />
"'Y;<br />
RECORD<br />
P : I NTEGEf;:;<br />
Q : ARRAY[:ttt3] OF TEXT<br />
END;<br />
The pointer type X points to record type Y, which contains a file<br />
component in field Q. The files denoted by Q are never closed until<br />
execution of the program terminates, unless you use the CLOSE<br />
procedure. For example, to close the files defined in the TYPE<br />
section above, you must call CLOSE with the parameters MA.Q[l],<br />
M A<br />
.Q(2], M".Q[31.<br />
You can assign the constant NIL to a pointer as follows:<br />
As a result of the assignment, the pointer variable M does not point<br />
to a variable. NIL is the only value you can specify to initialize a<br />
pointer.<br />
2-27