The Concurrent ML FAQ
Questions
- What version of SML/NJ should I use?
- How do I run a CML program?
- How do I compile a CML program?
- How do I use the SML/NJ Libary from a
CML program?
- Can I use the top-level print
function in a CML program?
- Can I use CML primitives at
top-level?
- Why does Int.toString occassionally return the wrong result?
Answers
What version of SML/NJ should I use?
CML works with both the latest released version of SML/NJ
(Version 110.0.7)
as well as with
recent working versions.
Since the recent working releases of SML/NJ are quite solid, we recommend them
over SML/NJ 110.0.7.
If you choose to use 110.0.7, then you may want to update your copy of CML
with a more recent version (also, see the note below).
How do I run a CML program?
It is not possible to execute CML code directly from the
SML/NJ top-level loop; instead one must invoke the main thread
of a CML program using the function RunCML.doit.
For example, the following is a self-contained CML program:
structure Main = struct
fun hi () = RunCML.doit (
fn () => TextIO.print "hello world\n",
SOME(Time.fromMilliseconds 10))
end
The second argument to RunCML.doit specifies the scheduling
quantum; if you specify NONE, then the default quantum
of 20 milliseconds is used.
How do I compile a CML program?
The recommended way to compile CML programs is to use the
SML/NJ compilation manager (CM) and to include ``cml.cm'' in your
project's CM file.
How do I use the SML/NJ Libary from a
CML program?
Some of the modules in the SML/NJ Libary are not thread safe;
therefore CML provides its own implementation of these library
modules.
To access modules from the SML/NJ Libary,
include ``cml-lib.cm'' in your project's CM file.
Can I use the top-level print
function in a CML program?
Yes, but your program must also include an explicit reference somewhere
to the TextIO module.
Without such a reference, the CML version of TextIO
does not get loaded
when your program is compiled and the print function resolves to the
SML/NJ version; since this version of print
is not thread safe, problems will result.
The most frequent symptom is mysterious deadlock.
Can I use CML primitives at
top-level?
Because channels, mailboxes, etc. that are bound at top-level (including
top-level bindings in modules) persist across multiple runs of a
CML program, they must be registered with the
CML run-time to ensure that they are initialized
each time RunCML.doit is called.
The RunCML structure has functions for registering top-level
channels and mailboxes.
Can I use CML on Windows?
CML has been ported to Windows (by Riccardo Pucella) and
is installed as part of the standand Windows installation.
There is a bug in the way that the SML/NJ 110.0.7 compiler handles 32-bit integers
across GC tests (they do not get preserved).
This bug has also caused problems with file handles on Windows, which are represented
by 32-bit words.
This bug is not present in recent working versions.
[
CML Home
|
SML/NJ Home
|
SML/NJ Library Home
]
Last updated on October 9, 2002.
Comments to John Reppy.