Unwind-protect Marc Nieper-Wißkirchen (09 Oct 2022 09:56 UTC)
Re: Unwind-protect Shiro Kawai (09 Oct 2022 10:41 UTC)
Re: Unwind-protect Marc Nieper-Wißkirchen (09 Oct 2022 11:21 UTC)
Re: Unwind-protect Shiro Kawai (09 Oct 2022 12:46 UTC)
Re: Unwind-protect Marc Nieper-Wißkirchen (09 Oct 2022 13:07 UTC)
Re: Unwind-protect Shiro Kawai (09 Oct 2022 13:26 UTC)
Re: Unwind-protect Marc Nieper-Wißkirchen (09 Oct 2022 13:58 UTC)
Re: Unwind-protect Shiro Kawai (09 Oct 2022 22:50 UTC)
Re: Unwind-protect Marc Nieper-Wißkirchen (10 Oct 2022 05:57 UTC)
Re: Unwind-protect Marc Nieper-Wißkirchen (10 Oct 2022 07:24 UTC)
Re: Unwind-protect Shiro Kawai (10 Oct 2022 07:25 UTC)
Re: Unwind-protect Marc Nieper-Wißkirchen (10 Oct 2022 07:39 UTC)
Re: Unwind-protect Shiro Kawai (10 Oct 2022 08:57 UTC)
Re: Unwind-protect Marc Nieper-Wißkirchen (10 Oct 2022 08:59 UTC)
Re: Unwind-protect John Cowan (09 Oct 2022 15:03 UTC)
Re: Unwind-protect Marc Nieper-Wißkirchen (09 Oct 2022 15:13 UTC)
Re: Unwind-protect Marc Nieper-Wißkirchen (09 Oct 2022 15:39 UTC)
Re: Unwind-protect Marc Nieper-Wißkirchen (09 Oct 2022 16:13 UTC)
Re: Unwind-protect Lassi Kortela (09 Oct 2022 15:41 UTC)
Re: Unwind-protect Marc Nieper-Wißkirchen (09 Oct 2022 16:11 UTC)
Re: Unwind-protect Marc Nieper-Wißkirchen (28 Oct 2022 11:08 UTC)
Re: Unwind-protect Vincent Manis (28 Oct 2022 18:53 UTC)
Re: Unwind-protect Marc Nieper-Wißkirchen (28 Oct 2022 18:58 UTC)
Re: Unwind-protect Vincent Manis (28 Oct 2022 19:14 UTC)
Re: Unwind-protect Marc Nieper-Wißkirchen (28 Oct 2022 19:28 UTC)
Re: Unwind-protect Arthur A. Gleckler (28 Oct 2022 19:31 UTC)

Re: Unwind-protect Marc Nieper-Wißkirchen 10 Oct 2022 07:39 UTC

Am Mo., 10. Okt. 2022 um 09:25 Uhr schrieb Shiro Kawai <xxxxxx@gmail.com>:
>
> I have no problems rewriting make-coroutine-generator to suit for srfi-226; in fact, Gauche's one is already written using delimited continuations (shift/reset).
> My concern is still whether srfi-226 allows (delimited) continuation-based coroutine to coexist seamlessly with unwind-protect.
> E.g. such coroutine based generator may be created by a third party and passed to my routine where I want to use unwind-protect:
>
> (lambda (g)
>    (unwind-protect
>         (... using (g) ...)
>      (cleanup)))
>
> (g) may already be called and have captured dynamic environments elsewhere.

Yes, this will work with a version based on delimited continuations.
It would be a problem if the dynamic extent of the procedure's body of
the coroutine generator is left and re-entered outside of yield while
processing the body. But this is expected of what we want from
unwind-protect.

(define g
  (make-coroutine-generator
    (lambda (yield)
      (call/cc
        (lambda (c)
          (abort-current-continuation (default-continuation-prompt-tag) c))))))

Here, the abortion to the default continuation prompt tag would leave
the dynamic extent of the generator procedure and thus of
unwind-protect. It will be reentered when the default prompt handler
invokes C.

With the second version of my make-coroutine-generator implementation
above, even this problem goes away: As the coroutine generator
procedure is evaluated in an initial continuation, no outside
continuation prompt would be visible.

> As far as I can write such coroutine using srfi-226 procedures, I'll rewrite existing libraries.

Great! Also, the specification of coroutine generators has to be made precise.