Contents | Prev | Next | Index
Variables of a pointer type P assume as values pointers to variables of another type T. T is called the pointer base type of P and must be a structured type (record, array, set, file, class, or class reference type). Notice that in this compiler, unlike standard Pascal, pointers to non-structured types, such as basic types, enumerations or subranges, are not supported, because Java references are only possible for structured types.
In the following language grammar for pointer types, language extensions are shown in red.
pointer_type ::= pointer_to type ::= pointer_to open_array type pointer_to ::= ^ open_array ::= ARRAY OF |
If p is a variable of type P = ^T, a call of the standard procedure NEW allocates memory from a heap and assigns the pointer variable to its address. The allocated memory is a new instance of type T. Standard procedure NEW is called as:
NEW( p )
If the language extensions are enabled via a compiler switch or directive, then if the pointer base type is an open array, the allocation has to be done as follows:
NEW( p, n )
where the additional actual parameter is an integer value specifiying the number of array elements.
An operand p designates a variable of its pointer type, whereas an operand p^ designates a variable of pointer base type T whose instance was allocated from the heap.
Any pointer variable may assume the value NIL, which points to no variable at all.
There is no need for explicitly deallocating memory blocks because this is automatically done by Java's garbage collection for the heap. Standard procedure DISPOSE(p) is still available, though. It only sets the pointer variable p to NIL, assuming that Java's garbage collection for unused memory blocks will eventually handle the rest.
Contents | Prev | Next | Index
Canterbury Pascal for JVM (Last documentation update
Sep 02, 2004)
Copyright © 1999-2004 J.Neuhoff - mhccorp.com
. All rights reserved.
Please send any comments or corrections to
neuhoff@mhccorp.com