Concurrent ML
Appearance
Concurrent ML (CML) is a concurrent extension of the Standard ML programming language.
Sample Code
Here is sample code to print "hello, world" to the console, using SML/NJ and CML:
cml_test.cm:
Library structure Main is cml_test.sml $cml/cml.cm $/basis.cm
cml_test.sml:
structure Main = struct fun test () = ( TextIO.print "hello, world\n"; TextIO.print "from a cml thread\n" ) fun hello () = RunCML.doit ( (fn () => ignore (CML.spawn test)) , NONE ) end
Running:
$ sml cml_test.cm Standard ML of New Jersey v110.55 [built: Mon Jan 16 16:54:23 2006] [scanning cml_test.cm] [parsing (cml_test.cm):cml_test.sml] [library $cml/cml.cm is stable] [library $cml/cml-internal.cm is stable] [library $cml/core-cml.cm is stable] - Main.hello (); [autoloading] [autoloading done] hello, world from a cml thread val it = 1 : OS.Process.status