Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

CPS can be kind of thought of like a normal programming language with the modification that every function takes an additional parameter "the rest of the program" and calls this instead of "return". Of course once this mechanism is in your language you might have multiple "rest of the program" parameters which the function can pick between.

I found this old thread talking a bit about the lisp condition system [1] which also mentions implementing it in a typed manner.

I used Lisp for a while myself as my favourite language (the condition system was part of the reason) but the problem I ended up switching to Haskell because it has much of the power macros provide coupled with a very strong type system. That's why the potential occurred to me that CPS can probably implement something effectively equivalent condition system.

[1] http://lambda-the-ultimate.org/node/1544



I see. I know that it is possible to transform primitive CL control flow operators into CPS, as it is shown on https://gitlab.common-lisp.net/cl-cont/cl-cont/-/blob/master..., so I assume that it is also possible a condition system into CPS as a derivative of those operators and then possibly optimize it further to take CPS-specific code traits into account.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: