Skip to main content

Subroutine

  • A named, reusable block of sequential instructions with a single entry point and a single exit point.
  • Invocation transfers control to the subroutine, which executes with its own local scope, optionally accepts parameters, may yield a return value, and always returns control to the caller upon completion.
  • Execution is synchronous and linear; suspension mid-execution is not supported.
  • Enables modularity, abstraction, and code reuse; distinguished from coroutines by lack of resumable suspension.

Links to This Note