Coroutines are computer program components that generalize subroutines for nonpreemptive multitasking, by allowing multiple entry points for suspending and resuming execution at certain locations. Coroutines are well-suited for implementing more familiar program components such as cooperative tasks, exceptions, event loop, iterators, infinite lists and pipes.
According to Donald Knuth, the term coroutine was coined by Melvin Conway in 1958, after he applied it to construction of an assembly program. The first published explanation of the coroutine appeared later, in 1963.
When subroutines are invoked, execution begins at the start, and once a subroutine exits, it is finished; an instance of a subroutine only returns once, and does not hold state between invocations. By contrast, coroutines can exit by calling other coroutines, which may later return to the point where they were invoked in the original coroutine; from the coroutine's point of view, it is not exiting but calling another coroutine. Thus, a coroutine instance holds state, and varies between invocations; there can be multiple instances of a given coroutine at once. The difference between calling another coroutine by means of "yielding" to it and simply calling another routine (which then, also, would return to the original point), is that the latter is entered in the same continuous manner as the former. The relation between two coroutines which yield to each other is not that of caller-callee, but instead symmetric.
Well she's my hot potato
She's my home dictator
Got her own sweet flavour
When I go down low
She's my girly Bono
She's my Yoko Ono
She goes oh no no no
But I love her so
You and me
Trying hard to build a family
You and me
Life is kind of phony
Holy matrimony
Dont you see
You and I were allways meant to be
I wont flee
All I wanna do is get down on my knees
Well she's my hot potato
She's my home dictator
Got her own sweet flavour
When I go down low
She's my girly Bono
She's my Yoko Ono
She goes oh no no no
But I love her so
Dont you see
You and I were allways meant to be
I wont flee
All I wanna do is get down on my knees
Well she's my hot potato
She's my home dictator
Got her own sweet flavour
When I go down low
She's my girly Bono
She's my Yoko Ono
She goes oh no no no
But I love her so
I saw her dance
I saw her smile
She crossed the floor
I reached for the door
She caught my eye
She made me cry
She tamed the sky
And made me fly
Well she's my hot potato
She's my home dictator
Got her own sweet flavour
When I go down low
She's my girly Bono
She's my Yoko Ono
She goes oh no no no
But I love her so
She's my hot potato
She's my home dictator
Got her own sweet flavour
She's my girly Bono
She's my Yoko Ono