2 Building Applications

2.7 The MLWorks batch compiler

You can compile source files without running the MLWorks interactive environment by invoking the MLWorks compiler as a batch process. MLWorks provides a script called mlbatch for this purpose. This script takes a series of unit names and produces object files from the unit sources. See the man page for mlbatch for more details.

However, you do not need to use mlbatch to compile files that are suitable for use outside the interactive environment. All files you compile in the interactive environment are compiled equivalently: every unit you compile down to an object file is compiled ready for execution outside the interactive environment. You can either pass it to the MLWorks runtime system with the mlpervasive script, or build it into a standalone executable file (see Section 2.6 on page 40).

But if you do want to execute applications you developed in the interactive environment outside the interactive environment, you must bear in mind that there are important differences between what we introduced in Section 1.5 as the batch context and the interactive context.

Recall that the interactive context is what is available to you in the interactive environment. We distinguish it from the batch context, which is what is available to a file being batch-compiled. The interactive and batch contexts both contain:

1. The Standard ML language.

2. The pervasive library, which is a built-in library available at top level in MLWorks. It is provided in the top-level structure MLWorks.

3. The Standard ML Basis library's General structure, and various top-level functions, exceptions, and types that the General structure defines. It is also built in to MLWorks at the top level.

The interactive context contains two further items:

4. The Shell structure, which is a collection of functions and options connected with the MLWorks interactive environment. Like the MLWorks and General structures it is always available at the top level.

5. Any modifications you make to the interactive context by causing declarations to be evaluated.

For instance, binding the identifier x to the value 5 counts as a modification of the interactive context: it introduces a new binding to the top level. You modify the interactive context similarly whenever you load units from source or object files.

The batch context does not include the last two items for good reason. The bindings you create in the interactive context are typically transient, and should not be allowed to affect how the compilation of a set a permanent application sources should turn out. The Shell structure is not ephemeral, but since it relates to details of the interactive MLWorks environment -- like the value-printer settings, editor preferences, and how to start running the GUI -- it makes no sense to make it visible in the batch context.


MLWorks User Guide (UNIX version 1.0) - 3 DEC 1996

Generated with Harlequin WebMaker