Is there a way to implement continuations in Erlang?

Is there a way to implement continuations in Erlang, like callcc in SMLNJ, Scheme and Ruby?

1 Like

You’d need to do a CPS-conversion.

1 Like

Using call/cc is not the same as implementing continuations.
It’s not clear what you want to know.
Do you want to know how to implement continuations in Erlang,
or do you want to know whether there is something you can use
to use continuations in Erlang?

There are many variants of the continuation idea.
“Escape” continuations can be simulated with exceptions.
Multi-use continuations will require you to find or write
a preprocessor to turn Erlang into continuation-passing style
The good news is that continuations are just functions, so no
new run-time system will be needed.

The obvious question is “what do you expect to gain by using
continuations?” I’ve been using Scheme for 30+ years and not
found much use for them. They don’t really interact well with
side effects.