Ch 6. Dynamic Variables [ HP Pascal/iX Programmer's Guide ] MPE/iX 5.0 Documentation
HP Pascal/iX Programmer's Guide
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.
MPE/iX 5.0 Documentation