6.13. kink/KONT_TAG

Provides shift/reset operations of tagged delimited continuation.

Using reset/shift pair, the continuation can be extracted as a function. Example:

If `shift` is not called, `reset` returns the result of $thunk.

The methods of `kont_tag` are described with sequences of abstract instructions. See Language specification → Evaluation section for abstract instructions and the abstract stack machine.

6.13.1. type kont_tag

`kont_tag` is a delimiter of a delimited continuation.

6.13.1.1. Kont_tag.reset($thunk)

`reset` delimits the continuation with `Kont_tag`.

At the tail of `reset`, the following sequence of abstract instructions is evaluated:

Precondition

$thunk must be a thunk.

6.13.1.2. Kont_tag.shift($abort)

`shift` makes a continuation function delimited by `Kont_tag`, moves to `Kont_tag`, and calls $abort with the continuation function.

At the tail of `shift`, the following sequence of abstract instructions is evaluated:

Preconditions

Kont_tag.can_shift? == true

$abort must be a function which takes a continuation function.

6.13.1.3. Kont_tag.can_shift?

`can_shift?` returns whether `shift` can be invoked for `Kont_tag` at the current stack.

At the tail of `can_shift?`, the following sequence of abstract instructions is evaluated:

6.13.2. KONT_TAG.new

`new` returns a new `kont_tag`.

6.13.3. KONT_TAG.is?(Val)

`is?` returns whether `Val` is a `kont_tag`.