3 ms·
It's not true that you need to use CPS to implemented first-class continuations. There are plenty of slow ways to do it, and even if you want to be fast you can
by samth 1y ago
It's not true that you need to use CPS to implemented first-class continuations. There are plenty of slow ways to do it, and even if you want to be fast you can do multiple different things. Dybvig describes a number of options in his thesis: https://www.cs.unc.edu/xcms/wpfiles/dissertations/dybvig.pdf https://www.cs.unc.edu/xcms/wpfiles/dissertations/dybvig.pdf
- ashton314 1y agoSam will definitely know more about this than I will, so if he contradicts me, listen to him. If I am not mistaken, the racket language does not convert to CPS during compilation. Instead, when you want to get the continuation, I think you just get a pointer to the stack frame that you want. All I know for sure is that it uses something called a-normal form, which is kind of like SSA in some ways, and that the continuation is 2x 64/32-bit words depending on your architecture.
- samth 1y agoThe main implementation of Racket today is built on top of Chez Scheme, which uses the techniques described by Dybvig that I linked to. In the earlier implementation of Racket, indeed it doesn't convert to CPS but does use something like A-normal form. There, continuations are implemented by actually copying the C stack.