The question: what does (call/cc call/cc) do in some program context, for example, something like:
(some-function arg1 (call/cc call/cc) arg3)
Approach 1 (a very inexact approach)
There's really only one continuation here, and there's not a lot you can do with that one continuation except return it, so a blind guess that is suprisingly correct is (call/cc (lambda (k) k)). That is, it just grabs the continuation and returns it.
Approach 2 (a more exact approach)
Use a calculus or semantics with rewrite rules.
Here I use a meaning function E which takes an expression, an environment(ρ), a store(σ) and a continuation(κ); a denotational style approach, but not very rigorous.
For clarity, I enumerate the two uses of call/cc: (call/cc1
, we grab the continuation and pass it to the argument call/cc2
Evaluating this second call/cc2
we grab the continuation and pass it to itself
Again, we discover that this is equivalent to (call/cc (lambda (k) k)):
E[(call/cc (lambda (k) k))]ρσκ
E[((lambda(k) k) κ)}ρσκ