The Scheme Programming Language says
Scheme allows the continuation of any expression to be captured with the procedure
call/cc
.call/cc
must be passed a procedurep
of one argument.call/cc
constructs a concrete representation of the current continuation and passes it top
. The continuation itself is represented by a procedurek
. Each timek
is applied to a value, it returns the value to the continuation of thecall/cc
application. This value becomes, in essence, the value of the application ofcall/cc
. Ifp
returns without invokingk
, the value returned by the procedure becomes the value of the application ofcall/cc
.
Are the two following ways of defining p
equivalent, as far as being called by call/cc
is concerned:
p
returns without invokingk
,p
callsk
with its otherwise return value?
I am not sure how call/cc
is defined.
Does call/cc
ever directly call the continuation k
, besides indirectly via p
calling k
?
Is it perfectly fine that both call/cc
and p
don't invoke continuation k
?