jargon

Design patterns·Who calls whom, and when

the function paused in the middle, handed back a value, and carried on from that exact line when asked for the next.

Generator

Also calledyield, coroutine generator, lazy sequence producer

A function that produces a sequence one element at a time, suspending its own execution between them. It is an iterator you write as ordinary straight-line code, which is what makes it so much easier to get right than a hand-written cursor. It is also how a sequence of unbounded or expensive elements becomes practical, because nothing beyond the current element is computed.

Commonly confused with