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.
Interpreting programsThe NetRexx interpreter is currently designed to be fully compatible with NetRexx programs compiled conventionally. There are some minor restrictions, but in general any program that NetRexxC can compile without error should run. In particular, multiple programs, threads, event listeners, callbacks, and Minor (inner) classes are fully supported.
To use the interpreter, use the NetRexxC command as usual and specify either of the following command options (flags):
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.
Interpreting Hints and TipsWhen using the translator as an interpreter, you may find these hints useful:
Interpreting PerformanceThe initial release of the interpreter, in the NetRexx 2.0 reference implementation, directly and efficiently interprets NetRexx instructions. However, to assure the stability of the code, terms and expressions within instructions are currently fully re-parsed and checked each time they are executed. This has the effect of slowing the execution of terms and expressions significantly; performance measurements on the initial release are therefore unlikely to be representative of later versions that might be released in the future.
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.
[previous | contents | next]