| Simulation of other Paradigms and Continuations - slide 37 : 43 |
Coroutines can be simulated in Scheme by (heavy) use of continuations
; In C1:
(let ((v ...) ; value to C2
(cont2 ...) ; continuation in C2
)
(let ((from-c2 ; value from C2 - received upon the next resume from C2
(call-with-current-continuation
(lambda (cont1) ; captured continuation in C1
(cont2 (cons v cont1)) ; resume C2 - pass v and cont1
))))
...
)
)






