Specification review; What are delimited continuation ? What is the advantage of delimited continuation ? Amirouche (11 May 2025 16:07 UTC)

Specification review; What are delimited continuation ? What is the advantage of delimited continuation ? Amirouche 11 May 2025 16:07 UTC

First it is very useful to have this, SRFI 248 (minimal delimited
continuations), SRFI 226 (Control Features), and SRFI 157 (Continuation
Marks) including many references, which helps at creating a durable
space for gathering information across the community about this subject.

I do not fully understand delimited continuations. So in the following I am
commenting, asking questions, and deliver some matter hoping to continue
the convo we started on IRC.

The point where I stand is: I skimmed, or read 157, 226 and 248 but not implemented them.

I can use  call/cc to return early e.g. in for-each. I can spit make-coroutine-generator
from the top of my head. I implemented a couple of coroutine-based systems including
a fork of guile fibers, and another one more like python's asyncio with scheme.
I used call-with-prompt. I struggle with amb. I tried shift/reset but it never occured
to me I will write a lazyseq with it when I built parser combinators, where if i
understand the various resources I read must be good use-case, because:

   it saves memory space (tm)

Also I built a parser in continuation-passing-style not limited by structure depth.

Long story short: I want to know more, and i need interaction with humans :)

## Abstract

 1.

    I think the abstract is too complex for what the library specification deliver;

 2.

    My understanding is that SRFI-248 at its core export new
    *implementation* for guard, raise, and raise-continuable that rely on
    delimited continuations;

 3.

    Shift and reset are never mentioned in the rest of the publication, very probably hidden in references;

 4.

    Since the only new feature of interest of delimited continuations
    is reducing memory use, it should be mentioned very clearly in the
    abstract.

## Rationale

 1.

    The rationale defer to pop culture "popular in other programming languages"

 2.

    Something like that should have been in the abstract: [reify] a [slice] of the
           rest of a computation

  3.

    Because the SRFI library is more about an exception system
    re-using under the cover delimited continuations forms, the rationale
    does not explain what, and why of delimited continuations; in particular
    since in my opinion, the sole advantage of delimited continuations is
    space use, it must be mentioned?

## Procedures

See typofix the at github at https://github.com/scheme-requests-for-implementation/srfi-248/pull/5

## Closing remarks

It is 100% clear to me that the SRFI is a proposal to use delimited
continuation to implement an exception system. Going through this SRFI,
or SRFI-226 does not help to understand why knowing call/cc I need to
know about delimited continuation, except because it does non-obvious control-flow.

I still do not understand delimited continuations. The abstract mention shift/reset
so here is the example from wikipedia [0]:

(*2(reset(+1(shiftk(k5))))) [0]
https://en.wikipedia.org/wiki/Delimited_continuation#Examples
I understand that shift will capture a continuation up-to reset, that is
k is a procedure equivalent to (lambda (x) (+ 1 x)) and call that
procedure, eventually evaluate to 14? I fail to understand in what
occasion I will want to do that. Maybe it is only demonstrating that
shift's k is:
a) equivalent to a procedure (so does call/cc?) b) that procedure is
"small" to help view the delimited in delcont, and imagine memory
saving. I went ahead and studied the other examples. I am confident
saying that is far from simpler than call/cc (I saw that argument
somewhhere). Tho, I get away with one thing, shift/reset, reset will
create a boundary, same with call-with-prompt that compiler can use to
optimize. Thanks for the hard work. And sorry for the late reply.