
1 Using MLWorks interactively
.sml to indicate that it contains Standard ML code; MLWorks will only treat files with the .sml suffix as source files. You can then edit the file as you would any other program, with a text editor. Notice that MLWorks saves all the code that has led to the current state of the interactive context. In particular, if you have had more than one listener, this option records all code typed into all your listeners, in the order in which it was evaluated. Since listeners all share the same context, the context created by running this file will be the same as that existing in any of your listeners at the point when you do the save.
If you have already used File > Save Source As in this MLWorks session, you can now simply choose File > Save Source instead, and MLWorks will update the file with any new source that you have entered since the last save.
Conversely, you may want to read ML code from a file in to your current context. There are various ways to do this; the simplest is to use the listener's File > Use File command. This produces a file dialog, and MLWorks will read code in from the file you choose as if it had been typed in to the listener window. The listener verifies all the declarations in the file, which must have a .sml suffix, in the usual way. In the example below, the file lists.sml was used; it contains definitions of a couple of simple list functions, length and flatten:
MLWorks> use "lists.sml"; val it : unit = () Use: lists.sml val length : 'a list -> int = fn val flatten : 'a list list -> 'a list = fn MLWorks>Note: The File > Use File command, in conjunction with the error-handling and editing facilities detailed in the next section, provides a handy way of interactively managing fairly small pieces of ML code. However, for larger or more complex sets of ML files, you should use the batch compilation system, documented in Chapter 2. The other entries on the listener's File menu are related to the batch compilation system.
You can save the state of your entire MLWorks session to a file with the Podium's File > Save Image command. MLWorks will prompt you for a filename in which to save the image, which is just a normal MLWorks image file (see Section 2.6). To restart the MLWorks session, use the mlimage script. This script is installed by default in the bin subdirectory of your MLWorks installation.
mlimage <filename> [ <args> ]See the UNIX manual pages for more on
mlimage.

Generated with Harlequin WebMaker