HP Pascal/iX Programmer's Guide (31502-90023)
6- 1
Chapter 6 Dynamic Variables
A
dynamic variable
is allocated during program execution. In contrast, a
global, module,
or
local
variable is allocated when the block containing
its declaration is activated.
Table 6-1 shows the differences between dynamic and static variables.
Table 6-1. Dynamic versus Static Variables
------------------------------------------------------------------------------------------------
|||||
||Dynamic Variable | Global or Module | Local Variable |
|||Variable ||
|||||
------------------------------------------------------------------------------------------------
|||||
| Declared? | No | Yes | Yes |
|||||
------------------------------------------------------------------------------------------------
|||||
| Referenced by | Pointer (which is | Name | Name |
| | declared). | | |
|||||
------------------------------------------------------------------------------------------------
|||||
| Allocated | During execution, | Before compilation | Upon entering |
| | with the function | unit executes. | procedure or function |
||
new
. | | that declares it. |
|||||
------------------------------------------------------------------------------------------------
|||||
| Stored on the | Heap | Static area | Stack |
|||||
------------------------------------------------------------------------------------------------
|||||
| Deallocated | During execution, | After program has | After exiting the |
| | with the procedure | executed. | procedure or function |
||
dispose
or
release
. | | that declares it. |
|||||
------------------------------------------------------------------------------------------------
This chapter explains:
* Pointer types peculiar to HP Pascal (
globalanyptr, anyptr
, and
localanyptr
).
* HP Pascal procedures
new
and
dispose,
which allocate and
deallocate dynamic variables.
* HP Pascal procedures
mark
and
release,
which allow an HP Pascal
program to deallocate a region of the heap that it no longer
needs.
* Intrinsic procedures
p_getheap
and
p_rtnheap
, which allow a
program written in any language that runs on the operating system
to allocate and deallocate a region of the HP Pascal heap.
GLOBALANYPTR Variables
The pointer type
globalanyptr
is assignment compatible with every pointer
type and the value
nil
.
Anyptr
is another name for the same type,
provided for compatibility with older Pascals. This manual uses the term
globalanyptr
exclusively, but
anyptr
can be substituted wherever it