IDL

FORWARD_FUNCTION

FORWARD_FUNCTION

The FORWARD_FUNCTION statement causes argument(s) to be interpreted as functions rather than variables (versions of IDL prior to 5.0 used parentheses to declare arrays).

Syntax


FORWARD_FUNCTION Name1, Name2, ..., Namen

Example


Ambiguities can arise between function calls and array references when a function has not yet been compiled, or when there is no file with the same name as the function found in the IDL path.

For example, attempting to compile the IDL statement:

A = xyz(1, COLOR=1)

will cause an error if the user-written function XYZ has not been compiled and the filename xyz.pro is not found in the IDL path. IDL reports a syntax error, because xyz is interpreted as an array variable instead of a function name.

This problem can be eliminated by using the FORWARD_FUNCTION statement. This statement has the following syntax:

FORWARD_FUNCTION Name"italic">1, Name"italic">2, ..., Name"italic">N

where Name is the name of a function that has not yet been compiled. Any names declared as forward-defined functions will be interpreted as functions (instead of as variable names) for the duration of the IDL session.

For example, we can resolve the ambiguity in the previous example by adding a FORWARD_FUNCTION definition:

; Define XYZ as the name of a function that has not yet been 
; compiled.
FORWARD_FUNCTION XYZ
 
; IDL now understands this statement to be a function call instead 
; of a bad variable reference.
a = XYZ(1, COLOR=1)
 

Note: Declaring a function that will be merged into IDL via the LINKIMAGE command with the FORWARD_FUNCTION statement will not have the desired effect. Routines merged via LINKIMAGE are considered by IDL to be built-in routines, and thus need no compilation or declaration. They must, however, be merged with IDL before any routines that call them are compiled.

Version History


Pre 4.0

Introduced

Notes


This page has no user notes yet. Be the first one!


This information is not subject to the controls of the International Traffic in Arms Regulations (ITAR) or the Export Administration Regulations (EAR). However, it may be restricted from transfer to various embargoed countries under U.S. laws and regulations.
© 2014 Exelis Visual Information Solutions