NetRexx User's Guide, version 2.02
Copyright (c) IBM Corporation, 2001. All rights reserved. ©
|Draft of 22 May 2001|
|[previous | contents | next]|
The startup time for running programs can therefore be significantly reduced as no Java source code or compilation is needed, and also the interpreter can give better runtime support (for example, exception tracebacks are localized to the programs being interpreted, and the location of an exception will be identified often to the nearest token in a term or expression).
Further, in a single run, a NetRexx program can be both interpreted and then compiled. This shares the parsing between the two processes, so the .class file is produced without the overhead of re-translating and re-checking the source.
To use the interpreter, use the NetRexxC command as usual and specify either of the following command options (flags):
after parsing, execute (interpret) the program or programs by calling the static main(String) method on the first class, with an empty array of strings as the argument. (If there is no suitable main method an error will be reported.)
as for -exec, except that the remainder of the command argument string passed to NetRexxC will be passed on to the main method as the array of argument strings, instead of being treated as file specifications or flags. Specifying -noarg is equivalent to specifying -exec; that is, an empty array of argument strings will be passed to the main method (and any remaining words in the command argument string are processed normally).
When any of -exec, -arg, or -noarg is specified, NetRexxC will first parse and check the programs listed on the command. If no error was found, it will then run them by invoking the main method of the first class interpretively.
Before the run starts, a line similar to:
===== Exec: hello =====will be displayed (you can stop this and other progress indicators being displayed by using the -verbose0 flag, as usual).
Finally, after interpretation is complete, the programs are compiled in the usual way, unless -nojava or -nocompile was specified.
For example, to interpret the hello world program without compilation, the command:
nrc hello -exec -nojavacan be used. If you are likely to want to re-interpret the program (for example, after changing the source file) then also specify the -prompt flag, as described above. This will give very much better performance on the second and subsequent interpretations.
Similarly, the command:
nrc hello -nojava -arg Hi Fred!would invoke the program, passing the words Hi Fred! as the argument to the program (you might want to add the line say arg to the program to demonstrate this).
You can also invoke the interpreter directly from another NetRexx or Java program, as described in the Using the NetRexxA API section.
For example, at present a loop controlled using loop for 1000 will be interpreted around 50 times faster than a loop controlled by loop i=1 to 1000, even in a binary method, because the latter requires an expression evaluation each time around the loop.
|||The -nojava flag stops any Java source being produced, so prevents compilation. This flag may be used to force syntax-checking of a program while preventing compilation, and with optional interpretation.|