3.3 Delivery tools: the Deliver structure

deliver

Function

Summary

Delivers an ML function into an image file or a standalone executable file.

Signature

MLWORKS.Deliver

Structure

MLWorks.Deliver

Type

val deliver: deliverer

Syntax

deliver file function executable? -> ()

Arguments

file
A string naming a file into which to write the image or executable.

function
An ML function to deliver. It must be of type unit -> unit.

executable?
A boolean value. If true, file will be a standalone executable; if false, file will be an image file.

Values

The deliver function returns unit.

Description

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.

Example

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> 


MLWorks Reference Manual (version 1.0) - 3 DEC 1996

Generated with Harlequin WebMaker