# delimited/undelimited continuation

Continuation is the **future** of the program, for example

(+ 3 2 (* 5 (+ 6 1) 8))

What is the continuation of `(+ 6 1)`

? We can get the result by
replacing `(+ 6 1)`

with a hole:

(+ 3 2 (* 5 ?hole 8))

By encoding continuation with the lambda, continuation of `(+ 6 1)`

is:

(lambda (x) (+ 3 2 (* 5 x 8)))

We can check it by `let/cc`

(+ 3 2 (* 5 (let/cc k (k (+ 6 1))) 8))

`k`

is the continuation, original result is `285`

, you may guess new
result will be `11405`

since `(+ 3 2 (* 5 285 8))`

is `11405`

. But,
actually the new result is still `285`

, because I do not tell all the
true. Continuation is not

(lambda (x) (+ 3 2 (* 5 x 8)))

but

(lambda (x) (exit (+ 3 2 (* 5 x 8))))

This is because end the program also was the **future** of program. Thus,
we have `(+ 3 2 (* 5 (exit 285) 8))`

that is `285`

, not
`(+ 3 2 (* 5 285 8)) = 11405`

. We call such continuation: undelimited
continuation.

## 1 Delimited continuation

So what is delimited continuation? By default, abort locates at the most out scope, delimited continuation means we can assign others location. To do so, we need some helper(the following code cannot work in racket, but just pseudo code):

(+ 3 2 (abort-here (* 5 x 8)))

Then the continuation would be:

(lambda (x) (exit (* 5 x 8)))

## 2 Conclusion

That's it, continuation can be parted to delimited and undelimited, now you know that :).