IMLPlus processes a program in a different manner from the IML procedure. The IML procedure processes a program one statement at a time. It reads a statement, parses the statement, executes the statement, and then moves on to the next statement. IMLPlus processes a program in three phases: a parse phase, a link phase, and a runtime phase. During the parse phase IMLPlus parses the entire program. During the link phase IMLPlus resolves all the calls to functions and subroutines. During the runtime phase IMLPlus executes the program statements.
This difference in processing behavior is usually insignificant, but in certain situations it is significant. With IMLPlus, all modules must be defined during the parse phase so the link phase can complete successfully. This is similar to the way many compiled languages operate. For example, you cannot run a C program until it has been compiled and linked with all the required functions.
Consider the following IML program:
print "Hello";
code = "start MyModule( x );
print x;
finish;";
call execute( code );
run MyModule( "World" );
If you run this program with the IML procedure, the program will print Hello followed by World. However, if you attempt to run this program with IMLPlus, IMLPlus will issue the following error message:
ERROR: IMLPlus could not find the module "MyModule".
IMLPlus requires that all modules be defined before the runtime phase of program processing.
If you need to delay the parsing and linking of particular statements until the runtime phase, use the EXECUTE subroutine. For example, the program shown above could be rewritten as follows:
print "Hello";
code = "start MyModule( x );
print x;
finish;";
call execute( code );
call execute( 'run MyModule( "World" );' );