Initiates spawning of the external program. Returns a Promise that will be kept with a Proc object once the external program exits or broken if the program cannot be started. Optionally, you can use a scheduler instead of the default $*SCHEDULER, or change the environment the process is going to run in via the named argument :$ENV or the directory via the named argument :$cwd.

will throw if the program exited with non-zero status, as the Proc returned as the result of the Promise throws when sunk and in this case it will get sunk outside the try. To avoid that, sink it yourself inside the try:

Creates a new Promise that runs the given code object. The promise will be kept when the code terminates normally, or broken if it throws an exception. The return value or exception can be inspected with the result method.

The scheduler that handles this promise can be passed as a named argument.

There is also a statement prefix start that provides syntactic sugar for this method:

# these two are equivalent:

my$p1=Promise.start({ ;#`( do something here )});

my$p2=start{ ;#`( do something here )};

As of the 6.d version of the language, start statement prefix used in sink context will automatically attach an exceptions handler. If an exception occurs in the given code, it will be printed and the program will then exit, like if it were thrown without any start statement prefixes involved.

usev6.c;

start{die}; sleep ⅓; say"hello"; # OUTPUT: «hello␤»

usev6.d;

start{die}; sleep ⅓; say"hello";

# OUTPUT:

# Unhandled exception in code scheduled on thread 4

# Died

# in block at -e line 1

If you wish to avoid this behavior, use start in non-sink context or catch the exception yourself:

# Don't sink it:

my$=start{die}; sleep ⅓; say"hello"; # OUTPUT: «hello␤»

# Catch yourself:

start{die; CATCH{default{say"caught"}}};

sleep ⅓;

say"hello";

# OUTPUT: «caught␤hello␤»

This behavior exists only syntactically, by using an alternate .sink method for Promise objects created by start blocks in sink context, thus simply sinking a Promise object that was created by other means won't trigger this behavior.

Creates a supply of supplies. For each value in the original supply, the code object is scheduled on another thread, and returns a supply either of a single value (if the code succeeds), or one that quits without a value (if the code fails).

This is useful for asynchronously starting work that you don't block on.