2.3 Using the MLWorks compilation system

2.3.3 Loading code into the environment

So far you have compiled source files into object files. No compiled objects have been loaded into the interactive environment; for instance, if you type the following at a listener prompt:

MLWorks> answer;

it generates an Unbound value error, even though sumxy.sml assigns a value to answer.

To load the object file for sumxy into the interactive environment, choose Build > Load Objects, making sure that sumxy is still selected in the Entries list.

Load sumxy 
Loading mo module zval 
Loading mo module xval 
Loading mo module yval 
Loading mo module sumxy 
processing result 
val answer : int = 15

As the compilation manager reports, the value of answer is now available in the interactive environment. Notice, however, that the values of x, y and z are not available; to make them available, you must explicitly load the units where they are defined.

The Build menu also has a Load from Source item. Choosing this causes MLWorks to read the source file for the selected unit (and any units on which it depends), evaluate it, and load the objects into the interactive environment without going through an intermediate object file. As loading from source, like compiling, involves evaluating ML source code, it in general takes much longer than just loading from an object file. The Compile and Load item, as you might expect, evaluates the source and both loads the result into the interactive environment and writes out an object file.


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

Generated with Harlequin WebMaker