Alternative topological sorting implementation Maxime Devos (13 Apr 2023 15:12 UTC)
Re: Alternative topological sorting implementation Marc Nieper-Wißkirchen (13 Apr 2023 15:29 UTC)
Re: Alternative topological sorting implementation Maxime Devos (13 Apr 2023 16:00 UTC)
Re: Alternative topological sorting implementation Marc Nieper-Wißkirchen (13 Apr 2023 20:18 UTC)
Re: Alternative topological sorting implementation Marc Nieper-Wißkirchen (13 Apr 2023 20:35 UTC)
Re: Alternative topological sorting implementation Maxime Devos (17 Apr 2023 21:33 UTC)
Re: Alternative topological sorting implementation Marc Nieper-Wißkirchen (18 Apr 2023 05:58 UTC)
Re: Alternative topological sorting implementation Maxime Devos (18 Apr 2023 07:53 UTC)
Re: Alternative topological sorting implementation Maxime Devos (17 Apr 2023 21:13 UTC)

Re: Alternative topological sorting implementation Marc Nieper-Wißkirchen 13 Apr 2023 20:34 UTC

PPS Maybe I should have better pointed to what I called liquids here:
https://github.com/mnieper/scheme-libraries#liquids.  Although one can
change them with set!, there is no mutation of a location in the store
happening, but just some delimited continuation wizardy.  The thing I
like about liquids is that they abstract away from the rather
low-level continuation primitives.

So you can just set! visiting and set! visited and are still doing
pure programming. :)  Liquids can be easily implemented in Guile.  Do
you think they would make a good addition?

Am Do., 13. Apr. 2023 um 22:18 Uhr schrieb Marc Nieper-Wißkirchen
<xxxxxx@gmail.com>:
>
> Am Do., 13. Apr. 2023 um 18:00 Uhr schrieb Maxime Devos
> <xxxxxx@telenet.be>:
> >
> >
> >
> > Op 13-04-2023 om 17:29 schreef Marc Nieper-Wißkirchen:
> > > Hi Maxime,
> > >
> > > Thanks for sharing your code!
> > >
> > > I don't see many delimited continuations at work, though.  The
> > > continuation-related primitive in your code is basically
> > > abort-to-prompt, which is here of equal power as C's longjmp or other
> > > languages throw/catch (and reflects the most typical use of Scheme's
> > > classical call/cc).  But maybe I miss something in your code.
> >
> > I won't comment on longjmp because that's too long ago for me.
>
> In Scheme terms, this just describes one-shot escaping continuations.
>
> > Maybe it is just throw/catch in disguise, but I don't see it -- on line
> > 57 + 66/70, the continuation is reinstated, which isn't something you
> > can do with throw/catch; you need raise-continuable/guard for that.
>
> Ah, I should have taken a closer look at Guile's primitives.  I only
> Racket's and the ones I wrote down in SRFI 226 by heart.  Guile's
> abort-to-prompt does not only abort to the prompt but also captures
> the delimited continuation, which I didn't know.  I looked for some
> instance of call/cc or call-with-delimited-continuation or the like.
>
> > I'm not sure if raise-continuable/guard is sufficient because there is
> > also a little state ('visiting' and 'visited') and I wanted to avoid
> > 'set!', but perhaps I'm just implementing 'set!' in terms of delimited
> > continuations here.
>
> Raise-continuable does no magic; guard uses continuations but mostly
> only to install the correct dynamic environment (and to be able the
> handler to escape with-exception-handler).  If catch/throw is not
> enough raise-continuable/guard is neither.
>
> The state (which you don't modify explicitly with set!) is hidden in
> the implicit continuation of Scheme's evaluation model.
>
> You may want to look at the "state handler" examples here:
> https://github.com/mnieper/scheme-libraries/blob/main/test-effect.scm.
>
> Cheers, and thanks for giving me an opportunity to learn about Guile's
> abort-to-prompt!
>
> Marc
>
> PS If you want your algorithm pure but without delimited
> continuations, I guess you have to change the for-each in line 51 into
> a fold so that you can explicitly move state around.
>
> >
> >  > [...]
> >
> > Greetings,
> > Maxime.