Heap Variables
Heap variables are a special class of IDL variables that have global scope and explicit user control over their lifetime. They can be basic IDL variables, accessible via pointers, or objects, accessible via object references. (See Creating Custom Objects in IDL (Object Programming) for more information on IDL objects.) In IDL documentation of pointers and objects, heap variables accessible via pointers are called pointer heap variables, and heap variables accessible via object references are called object heap variables.
Note
Pointers and object references have many similarities, the strongest of which is that both point at heap variables. It is important to understand that they are not the same type, and cannot be used interchangeably. Pointers and object references are used to solve different sorts of problems. Pointers are useful for building dynamic data structures, and for passing large data around using a lightweight token (the pointer itself) instead of copying data. Objects are used to apply object oriented design techniques and organization to a system. It is, of course, often useful to use both in a given program.
Heap variables are global in scope, but do not suffer from the limitations of COMMON blocks. That is, heap variables are available to all program units at all times. (Remember, however, that IDL variables containing pointers to heap variables are not global in scope and must be declared in a COMMON block if you want to share them between program units.)
Heap variables:
- Facilitate object oriented programming.
- Provide full support for Save and Restore. Saving a pointer or object reference automatically causes the associated heap variable to be saved as well. This means that if the heap variable contains a pointer or object reference, the heap variables they point to are also saved. Complicated self-referential data structures can be saved and restored easily.
- Are manipulated primarily via pointers or object references using built in language operators rather than special functions and procedures.
- Can be used to construct arbitrary, fully general data structures in conjunction with pointers.
Note
If you have used versions of IDL prior to version 5, you may be familiar with handles. Because IDL pointers provide a more complete and robust way of building dynamic data structures, we recommend that you use pointers rather than handles when developing new code. See IDL API History (IDL Reference Guide) for a discussion of our policy on language features that have been superseded in this manner.