gnd

The await operation blocks until a background task created with async finishes. If the task ends normally, await returns the routine’s output. If the task ends by executing throw, the await itself raises that error message. Thus await either yields a value or propagates the task’s error.

The syntax of await is:

[ $destination ] await [ task ]

Examples

Wait for an explicit task variable:

$task  async heavyWork
$out   await $task            # on success _ becomes the routine's result

Using the default _ shorthand:

$task async buildReport
await                       # same as await $task
log report done

Sequentially await two tasks:

$t1 async stepA
$t2 async stepB
await $t1
await $t2

Error behaviour

await never mutates its operand; it blocks the current routine, produces exactly one value on success, and follows single-assignment rules.