Re: Specification review; What are delimited continuation ? What is the advantage of delimited continuation ?
Marc Nieper-WiÃkirchen 11 May 2025 16:25 UTC
Am So., 11. Mai 2025 um 18:07 Uhr schrieb Amirouche <xxxxxx@amirouche.dev>:
>
> 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.
SRFI 248 is a specification for Scheme. It is neither a tutorial nor a
reference about delimited continuations. It assumes that you know the
concept of delimited continuations.
> 4.
>
> Since the only new feature of interest of delimited continuations
> is reducing memory use, it should be mentioned very clearly in the
> abstract.
That's untrue. Delimited continuations are not about reducing memory
use. The only connection to memory use is that when call/cc is used in
a hacky way as a substitute for true delimited continuations, space
leaks may occur.
> 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?
No, the SRFI is not about an exception system. It is really about
delimited continuations. What it does is to reuse some infrastructure
that deals with the dynamic environment so that its API can be truly
minimal in the spirit of the Scheme language.
> 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:
In the case of the examples "make-coroutine-generator" and
"for-each->fold", you can see that the captured delimited
continuations serve a real purpose.
Marc