(+ 2 (let/cc cont
(begin
(set! global-cont cont)
3)))
5
global-cont
#<continuation>
(global-cont 5) ; global-cont: (+ 2 _)
7
I know the whole block (+ 2 ... 3)))
is a continuation. But why global-cont
is a continuation also? I tried to check the let/cc
document, but it's hard to understand.
In this expression:
(let/cc cont body ...)
cont
is a continuation (+ 2 _)
, and in the body you're doing this:
(set! global-cont cont)
So basically you're assigning cont
to global-cont
, making it also a continuation.