Difficulty: Easy
Correct Answer: Coroutine
Explanation:
Introduction / Context:
In programming language theory and systems programming, there are control-flow constructs that go beyond simple function calls and returns. One such construct enables two routines to cooperatively pass control back and forth, producing sequences or state machines elegantly. This question asks you to identify that component.
Given Data / Assumptions:
Concept / Approach:
A coroutine is a generalization of a subroutine. Unlike a function that returns once, a coroutine can yield multiple times, pausing its execution state and later resuming. Coroutines are ideal for generators, cooperative multitasking, and iterative producers/consumers.
Step-by-Step Solution:
Verification / Alternative check:
Languages such as Python (generators/async), Lua (coroutine library), and C# (async/await with state machines) provide coroutine-like behavior to structure complex workflows without explicit threads.
Why Other Options Are Wrong:
Common Pitfalls:
Final Answer:
Coroutine.
Discussion & Comments