Hacker News new | ask | show | jobs
by thdhhghgbhy 256 days ago
It's powerful, but is anyone actually using it other than in hobby projects that is, in any language?
6 comments

Java's new green threads are built on delimited continuations.
Delimited continuations have been implemented in the de-facto standard Haskell runtime system, the GHC runtime system [0]. The goal was to make effect systems more performant [1], but I believe that work has stalled due to the maintainer shifting priorities.

[0]: https://github.com/ghc-proposals/ghc-proposals/blob/master/p...

[1]: https://blog.poisson.chat/posts/2023-01-02-del-cont-examples...

Well the delimited continuation primops are there in ghc for anyone to use. But even with the proliferation of effects libraries in Haskell, I haven't heard a whisper of any of them using the delimited continuation primitives in ghc. There was one very expwrimental extension to Bluefin from memory, but that's it.
That's Bluefin Algae, which isn't as such an extension to Bluefin, but a library that wraps delimited continuations in a Bluefin-style API. As far as I know, no one has really used it yet.

[1] https://hackage.haskell.org/package/bluefin-algae

By "it" do you mean delimited continuations? If so, my understanding is that they are the standard mode of interruption in Racket — all error-raising/handling and other continuation forms (call/cc, etc) are implemented in terms of delimited continuations because they're a more general abstraction than the older primitives. You can read about Racket's continuation model and where they're used in §10.4 of the Racket Reference [1].

[1] https://docs.racket-lang.org/reference/cont.html

I may be incorrect, but isn't call/cc+state equivalent to delimited continuations? I.e. one can be implemented with the other (and IIRC Racket does have state)
Oleg covers this on his page "An argument against call/cc" (which is linked). The long-and-short of it is: only in a toy-like way; in practice even call/cc + state are insufficient primitives.

https://okmij.org/ftp/continuations/against-callcc.html#trap...

Thanks!
>delimited continuations?

Yes, sorry typed this up on the run.

No worries, just wanted to clarify to make sure my response was on-topic!
The Ocaml 5 effect system is based on delimited continuations, and its new effect-based IO library, Eio, seems to be getting more and more popular all the time.
Exceptions with throw/catch are 90% of the way to delimited continuations so in a sense everyone is already using a close subset of it!

They could be useful in typical exception handling contexts where the operation could be retried. An operation involving a file read that fails due to file not being found could be body could be resumed with dummy data or data sourced from alternative locations. Lisps also like to show a REPL and allow the programmers to plug in the value themselves.

They are required for any compliant Scheme implementation.