I am studying call/cc
in Racket along the lines of paper Continuations by example: Exceptions, time-traveling search, generators, threads, and coroutines 1.
The paper mentions that the most advantageous API is derived from call/cc
by providing a procedure lambda (cc) (cc cc)
. I understand this specific call/cc
invocation returns the current continuation first-class object to the main program.
In the example that follows, the paper calls all this (right-now)
.
What I see is that inside that same example the cc
object returned by the abovementioned call/cc
invocation is always run afterwards by applying it to itself. That's what I don't understand.
I don't see what is so special in cc
as value, so I have tried to start it as a function with (cc ())
, or (cc (lambda () ()))
, or even (cc "whatever")
and (cc)
. No joy whatsoever: apparently the continuation wants just that application to itself in order to start to run.
Why is that? What is an example that clearly illustrates the uniqueness of running cc's by doing (cc cc)
?