HP Pascal/iX Programmer's Guide (31502-90023)
2-: 10
GLOBAL/EXTERNAL Limitations.
The following are some limitations of using GLOBAL/EXTERNAL:
* All global variables must be declared in the GLOBAL compilation
unit.
* Using GLOBAL/EXTERNAL results in slower link time.
* Code that references global variables is not as efficient as code
that does not use GLOBAL/EXTERNAL.
Using SUBPROGRAM with GLOBAL
The SUBPROGRAM with GLOBAL compiler options result in Pascal programs
that are a mixture of subprogram and global compilation units. These
compiler options must precede the reserved word PROGRAM.
Global variables declared here can be referenced in external compilation
units.
When to Use SUBPROGRAM with GLOBAL.
Use SUBPROGRAM with GLOBAL to allow multiple declarations of additional
global variables instead of using just the outer block.
SUBPROGRAM with GLOBAL Advantages.
When you use SUBPROGRAM with GLOBAL, you do not have to recompile the
outer block if you are not using GLOBAL. This method of separate
compilation is similar to using modules.
You don't have to share all variables with other languages, you can share
only a few variables, if you wish.
If any of the global variables change, you only need to recompile the
units that refer to them.
You can use this to put globals into an XL.
External Interfaces
Your program can interface with its external environment (other routines
and files supported by the operating system) by using physical files,
external routines, and intrinsics.
A
physical file
is a program-independent entity that the operating system
maintains. It can be a permanent file on a disk or other medium, or it
can be an interactive file created at a terminal. Your program can
manipulate a physical file by associating it with a logical file (a file
that the program declares). Chapter 3, "Input/Output," explains physical
and logical files, which HP Pascal programs use for input/output.
An
external routine
is a routine that is not in the compilation unit that
calls it. Its source language can be HP Pascal, HP C, HP COBOL II/XL, HP
FORTRAN 66/V, HP FORTRAN 77, or SPL. Your program can access an external
routine by declaring it with the EXTERNAL directive. Chapter 9 explains
external routines.
An
intrinsic
is an external routine that can be called by a program
written in any language that the operating system supports. An intrinsic
can be written in any supported language, but its formal parameters must
be of types that have counterparts in all the other supported languages.
Your program can access an intrinsic by declaring it with the INTRINSIC
directive. You need not declare the intrinsic's entire parameter list,
and your program can use an intrinsic function as either a function or a
procedure. Refer to Chapter 10 for more information on intrinsics.