call/cc is trivial to implement. The hard part is setting up the environment where it is possible to implement.

We must first define a continuation-passing style (CPS) execution environment. In this environment, your functions (or function-like things) don't directly return values; instead, they are passed a function that represents the 'next step' in the computation - the 'continuation' - and they pass their result there. In Haskell, this looks like this:

newtype Cont r a = Cont { runCont :: (a -&gt; r) -&gt; r }


As you can see, a Cont monad action is really a function that takes a continuation (a -&gt; r), passes a result a to the continuation, and gets back a final result of r, which it simply passes through to its caller (ie, a Cont monad action should tail call into the continuation). runCont just takes it out of the newtype wrapper - you could also think of it as invoking an action with some particular continuation, as in runCont someAction someContinuation.

We can then turn this into a monad:

instance Monad (Cont r) where
    return x = Cont $ \cc -&gt; cc x
    (Cont f) (&gt;&gt;=) g = Cont $ \cc -&gt; f (\r -&gt; runCont (g r) cc)


As you can see, return just gets a continuation cc, and passes its value to the continuation. (&gt;&gt;=) is a bit trickier, it has to invoke f with a continuation that then invokes g, gets the action back, and then passes the outer continuation to this new action.

So given this framework, getting at the continuation is simple. We just want to invoke a function with its continuation twice. The tricky part is we need to rewrap this continuation in a new monadic action that throws out the existing continuation. So let's break it down a bit:

-- Invoke a raw continuation with a given argument, throwing away our normal 
-- continuation
gotoContinuation :: (a -&gt; r) -&gt; a -&gt; Cont r x
gotoContinuation continuation argument = Cont $ \_ -&gt; continuation argument

-- Duplicate the current continuation; wrap one up in an easy-to-use action, and
-- the other stays the normal continuation for f
callCC f = Cont $ \cc -&gt; runCont (f (gotoContinuation cc)) cc


Simple, no?

In other languages like Scheme, the principle is the same, although it may be implemented as a compiler primitive; the reason we can do it in Haskell is because the continuation-passing was something we defined in Haskell, not at a lower level of the runtime. But the principle is the same - you need to have CPS first, and then call/cc is a trivial application of this execution model.

call/cc implementation?
Sometimes, I feel to contact some of the eminent researchers in my field for any of the following reasons:


Appreciating their research publication (recent times). They publish in top conferences, which are usually not hosted in my country or nearby.
Requesting comments on some of my research hypothesis
Sometimes just because I am a die hard fan of them. For example, probably the only reason I continued with research in Computer Science was due to Don Knuth.
Sometimes, to know what they think on some specific research area that has propagated due to there work. (Probably looks like some journalistic work)
For knowing how did they tackle the pressures or certain situation during their PhD or research. (Yes, it's vague but these questions come to mind and probably should be answered by oneself or personal interaction, but adding it for the sake of completion)


Since, most of them are located outside my country, I can't visit or phone them. So, how are such emails perceived. Is it appropriate to send such emails, given that they are expected to have very busy schedule and it would probably waste their time?

Though I have mentioned my field as Computer Science, the question should be applicable to all the fields. 
