Common Lisp the Language 2nd Edition


next up previous contents index
Next: Backquote Up: Generators and Gatherers Previous: Gatherers

B.4. Discussion

change_begin
The idea of generators and gatherers was first proposed by Pavel Curtis. A key aspect of his proposal was the realization that generators and gatherers can be implemented simply and elegantly as closures and that these closures can be compiled very efficiently if certain conditions are met.

First the compiler must support an optimization Curtis calls ``let eversion'' in addition to the optimization methods presented in [45]. If a closure is created and used entirely within a limited lexical scope the scopes of any bound variables nested in the closure can be enlarged (everted) to enclose all the uses of the closure. This allows the variables to be allocated on the stack rather than the heap.

Second for a generator/gatherer closure to be compiled efficiently for a generator/gatherer closure to be compiled efficientlystackted and used entirely within a_motif.gif">