In a language which supports continuation, e.g. Scheme, Ruby, and Haskell, suppose there is a function cc' which takes no argument and return the current continuation, so that the caller that obtains a continuation by calling cc' can then invoke the continuation anywhere and as often as it likes.
cc' can be written in terms of the CPS-styled call/cc, by passing an identity function as an argument to call/cc.
Conversely, can the CPS-styled call/cc be written in terms of the non-CPS-styled cc'?
call/cc(f) = f(cc)? - rampiong(call/cc(f)) = g(f(cc)) = call/cc(g . f), where the last.denotes function composition, and this is clearly not what we want. The point is that, intuitively,fshould receive the continuation "withoutfitself", whenf(cc)includesfin the continuation. - chiContT rmonad transformer and various CPSish things likeCodensity), but there is no support whatsoever for undelimited continuations like Scheme has. - dfeuer