Function
Delivers an ML function into an image file or a standalone executable file.
MLWORKS.Deliver
MLWorks.Deliver
val deliver: deliverer
deliver file function executable? -> ()
unit -> unit.
true, file will be a standalone executable; if false, file will be an image file.
deliver function returns unit. Delivers an ML function into an image file or a standalone executable file.
If standalone? is true, file can be executed standalone. If false, file can be executed by passing it to the MLWorks runtime.
When deliver is called on a function, MLWorks performs a garbage collection to remove as much irrelevant code as possible. After garbage collection, MLWorks writes the delivered function to file.
Note: Under Windows, MLWorks exits once delivery is complete, whereas under UNIX, it continues to operate.
Consider the following function:
fun hello() = print "Hello, world.\n";
To deliver a standalone executable version of it, call:
deliver ("hello", hello, true);Then to run it, on the OS command line, call:
> hello Hello, world. >
To deliver an image file of it, call:
deliver ("hello.img", hello, false);Then to run it, go to the OS command line. On Windows, produce an MS-DOS prompt and call:
dos> bin\mlimage-console hello.img Hello, world. dos>
On UNIX, call:
unix> bin/mlimage hello.img Hello, world. unix>