Method yield()

Method yield

mixed yield(mixed|void val)


Stop execution of the current restartable function for now, and return the value val.

Parameter val

Value to be returned from the restartable function.

May be omitted in functions returning void (including asynchronous functions). For asynchronous functions this means that Concurrent.Promise()->success() in the implicit Concurrent.Promise will not be called.


Evaluates to the first argument passed to the restartable function on restart, or if it has already been called, the value passed at that time.

Calling this special form is similar to the statement:

continue return val;

This syntax is however an expression and can thus be used to pass a value back.


Use of this function is only valid in restartable functions.


The second argument to a restartable function may be a function that throws a value. That value will appear to have been thrown via yield().

See also

await(), Restartable functions