Some Tips on Using CML

It is important that you have a direct use of the TextIO module in your program. This ensures that the CML version of TextIO is used which is properly thread-safe. Defining a function like the following somewhere will do the trick.

fun toErr s = TextIO.output(TextIO.stdErr, s)

To use any of the SML/NJ library modules use cml-lib.cm in place of smlnj-lib.cm in your CM files. This will ensure that CML-compatible versions are used. This library also contains the Multicast and TraceCML structures.

You can export your program to a heap using SMLofNJ.exportFn. CML is not started until the call to RunCML.doit in the main function. You can do no CML operations before it is started except that you can create some data structures such as channels, synchronous variables and mailboxes.