News for hackers. Stuff that matters.
Re:Beautiful ideas in programming: generators and continuations by compressedgas on Tuesday August 03, 2021 @12:48PM (#28051360)
I think that they are each expressible with the other.

Monadic reflection can be implemented with continuations. Effects, specifically effect handlers, can be implemented with delimited continuations which weren't mentioned in this article. Delimited continuations and undelimited continuations can implement each other. Both undelimited continuations and delimited continuations can be implemented as a monad.

The main issue with all of this and why effects exist and why monads and delimited continuations aren't enough has to do with the fact that delimited continuations can't be easily type checked and monads aren't open for extension.

I did not like that undelimited continuations were not mentioned. They are so much easier to understand than call/cc continuations as they are the rectification of some segment of the return stack as a function which when called returns through that segment and then to the caller like a regular function.

Re:Beautiful ideas in programming: generators and continuations by hencq on Tuesday August 03, 2021 @02:38PM (#28052555)
> I did not like that undelimited continuations were not mentioned.

call/cc continuations are undelimited continuations right? It sounds like you're talking about call/ec, escape continuations or one-shot continuations. They're essentially longjmp in C.

Re:Beautiful ideas in programming: generators and continuations by compressedgas on Tuesday August 03, 2021 @09:28PM (#28056262)
I meant delimited. However copy and paste had other plans.

All of call/cc, call/ec, call/1cc are effectively jumps to a saved stack. (The difference between these is that the first can be used more than once and both to enter and exit. The second can only be used to exit. The third can only be used once.)

shift is instead captures the return stack up to the first reset and forms a function out of it that when called runs the rest of each of the frames before returning to the caller of that created function.

Re:Beautiful ideas in programming: generators and continuations by a1369209993 on Tuesday August 03, 2021 @08:34PM (#28055952)
> I did not like that undelimited continuations were not mentioned. They are so much easier to understand than call/cc continuations as they are the rectification of some segment of the return stack as a function which when called returns through that segment and then to the caller like a regular function.

I think you mean delimited continuations? "Undelimited continuations" is call/cc.

Re:Beautiful ideas in programming: generators and continuations by compressedgas on Tuesday August 03, 2021 @09:11PM (#28056172)
I edited that sentence when I forgot the 'not' but I missed removing the 'un'. Yes, shift and reset, delimited continuations were not mentioned.
Re:Beautiful ideas in programming: generators and continuations by ashton314 on Tuesday August 03, 2021 @02:30PM (#28052466)
Can you recommend some papers on this?
Re:Beautiful ideas in programming: generators and continuations by manu3000 on Tuesday August 03, 2021 @06:02PM (#28054784)
Oleg has written a lot about this: http://okmij.org/ftp/continuations/

you can also google "oliver danvy delimited continuations" or "felleisen delimited continuations"