#separator:tab
#html:true
#notetype:Basic
#tags column:3
#deck:cracked.guide::TAOCP Vol 1::1.4.2 Coroutines
#columns:Front	Back	Tags
TAOCP §1.4.2 Coroutines: what does it cover?	Coroutines: routines that call each other as equals, each resuming where it left off. Knuth shows a pipeline example where one coroutine produces characters and another consumes and transforms them.	cracked.guide cracked.guide::phase::taocp-1 cracked.guide::section::1.4.2 cracked.guide::kind::about
TAOCP §1.4.2: why does it matter?	Generators, async/await, Go's goroutines and Lua coroutines all descend from this idea. Seeing it in assembly makes the &quot;where does my state live&quot; question concrete.	cracked.guide cracked.guide::phase::taocp-1 cracked.guide::section::1.4.2 cracked.guide::kind::why
TAOCP §1.4.2, a common trap: “Thinking coroutines need threads.” What's the catch?	They do not; they are just saved resume points.	cracked.guide cracked.guide::phase::taocp-1 cracked.guide::section::1.4.2 cracked.guide::kind::trap
TAOCP §1.4.2, exercise 2 (rated 20, recommended): what is it asking?	Predict what happens if the other coroutine runs first.	cracked.guide cracked.guide::phase::taocp-1 cracked.guide::section::1.4.2 cracked.guide::kind::exercise
TAOCP §1.4.2, exercise 3 (rated 20): what is it asking?	A true-or-false about the example's comparisons that rewards careful reading.	cracked.guide cracked.guide::phase::taocp-1 cracked.guide::section::1.4.2 cracked.guide::kind::exercise
TAOCP §1.4.2, exercise 4 (rated 20): what is it asking?	Show coroutine linkage on a real machine or language you know.	cracked.guide cracked.guide::phase::taocp-1 cracked.guide::section::1.4.2 cracked.guide::kind::exercise
TAOCP §1.4.2, exercise 5 (rated 15): what is it asking?	Make the coroutine switch preserve a register across jumps.	cracked.guide cracked.guide::phase::taocp-1 cracked.guide::section::1.4.2 cracked.guide::kind::exercise
TAOCP §1.4.2, exercise 6 (rated 22, recommended): what is it asking?	Extend coroutine linkage to three coroutines.	cracked.guide cracked.guide::phase::taocp-1 cracked.guide::section::1.4.2 cracked.guide::kind::exercise
TAOCP §1.4.2, exercise 7 (rated 30, recommended): what is it asking?	Write the reverse translator from the text's example as a MIX program. The stretch.	cracked.guide cracked.guide::phase::taocp-1 cracked.guide::section::1.4.2 cracked.guide::kind::exercise
TAOCP §1.4.2: how many exercises, and how are they rated?	7 exercises, rated 10 to 30.	cracked.guide cracked.guide::phase::taocp-1 cracked.guide::section::1.4.2 cracked.guide::kind::exercises
TAOCP §1.4.2: what should you be comfortable with first?	<ul><li>1.4.1 Subroutines</li></ul>	cracked.guide cracked.guide::phase::taocp-1 cracked.guide::section::1.4.2 cracked.guide::kind::prereqs
TAOCP §1.4.2: how should you work through it?	Trace the example with two columns on paper, one per coroutine, marking where control jumps. Then rewrite the example with Python generators or JavaScript generators and see how much simpler it gets.	cracked.guide cracked.guide::phase::taocp-1 cracked.guide::section::1.4.2 cracked.guide::kind::approach
