# Subroutine

A special block that executes a subset of blocks in a new fiber and waits for it to stop, optionally with results.

The current fiber will pause until the newly created subroutine fiber has stopped, the subroutine fiber will proceed immediately without pause.

This block has both an OK and a NEW outcome. The NEW path is executed by the newly created subroutine fiber, the OK path is executed, as usual, by the current (calling) fiber.

The subroutine fiber will run independently but will stop with the calling fiber. Variable values are also independent, the subroutine fiber starts with a clone of the current (calling) fiber variables, so modifying a variable in one fiber doesn’t affect the other fiber, unless it’s a returned variable.

Note! If the NEW path reconnect back to the main path in the parent fiber, it will exponentially create more and more fibers. This is called “recursion” and should be used with caution.

## Returned variables

The values of the returned variables are copied back to the calling fiber from the subroutine fiber when it stops.