REPL Argument Processing

As built, the main function comes form the repl module, which interprets the arguments as flags and names of files to be loaded. The following flags are understood:

Table 14-2. RScheme Shell Flags

-c pathSave bootable image.
-c.repl pathSave bootable image with REPL's main as the main function.
--Interpret remaining arguments as application arguments.
-exitExit successfully.
-e exprEvaluate expression expr.
-m [module=]fileLink module module from mif at file. If module is not specified, the name will be the base name in file.
+moduleImport module module

The default behavior is to interpret each of the other command-line arguments as the name of a file to load.

When we start the RScheme system, we can use command-line arguments to incorporate compiled modules and to execute expressions, and possibly to save the resulting image to an image file. The general syntax of the rs command is described above.

Each module-or-eval-argument is handled in the order given on the command line and can be -m foo.mif, +foo, or -e expr. Using -m foo.mif means that the code for the module foo is loaded into RScheme, but the exported variables in foo are not made visible until a ,(use foo) command is executed. Using +foo means that the module is loaded in the same way as with -m foo.mif, but in addition the exported variables in foo are made visible to the current module as if ,(use foo) had been typed. Using -e expr means evaluating an RScheme expression. Thus rs +foo is rougly equivalent to rs -m foo.mif -e ",(use foo)", but -e can of course be used to evaluate any valid RScheme expression.

Finally, the argument -c file.img saves the RScheme image resulting from the other arguments.