Question

I'm struggling to understand the concept of Continuations (as used in Seaside with Smalltalk). A snippet from Wikipedia says:

"... refer to first-class continuations, which are constructs that give a programming language the ability to save the execution state at any point and return to that point at a later point in the program..."

Isn't this simply another way of expressing what an assembler programmer would do when programming an interrupt? Or have I completely missed the point!

Was it helpful?

Solution

A continuation can be seen as a snapshot copy of the running process. Capturing a continuation means that the current process is copied and put aside. After that, code continues to execute normally. Evaluating a continuation means that the current process is terminated and the copied one is resumed in exactly the state it was captured. Continuations can typically be resumed multiple times.

An interrupt is more like a coroutine, where there are two different execution threads (application code, interrupt handler) that interleave each other.

OTHER TIPS

Continuations are roughly equivalent to setjump/longjump in C. You can expect your context be intact when you call the continuation (stack, flags, registers, instruction pointer and so on) after leaving it. So it is similar to a software interrupt call except you don't have to return (or more accurately, call the continuation) after the handler finishes and the continuation is not implicit.

In some ways they are similar. However, continuations are called by the program itself, and interrupts are usually generated by the CPU or devices on the computer. Also, an interrupt is more like a C signal, it is just called and then control returns to the program. The interrupt is responsible for saving state and restoring it afterwards.

Also, it should be noted that you can implement continuations quite easily in assembler.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top