5 ms·
i wish more languages provided call-cc. some languages let you freeze/restore a single stack frame, but it's unfashionable these days to freeze/restore an entir
by rahimiali 6y ago
i wish more languages provided call-cc. some languages let you freeze/restore a single stack frame, but it's unfashionable these days to freeze/restore an entire call chain. i find it to be a clean building block for all sorts of operations, like undo, multithreading, exception handling, etc. i missed this feature so much in python that i added it as a library [0].
[0] https://github.com/a-rahimi/python-checkpointing2 https://github.com/a-rahimi/python-checkpointing2
- viraptor 6y agoWouldn't it be safer to have a purpose-built state save and restore? This is a cool trick and will work in tightly controlled situations, but I wouldn't be comfortable using it with any third party library (so any non-trivial app) or if there's a chance of version update which changes state structure.
- anonymoushn 6y agoWhy not use greenlet? does it lack serializability?
- rahimiali 6y agogreenlet good! i'll check if it saves & restores the entire callchain or if it only works on the current frame like generators and async already do.
- anonymoushn 6y agoIt's real coroutines. I used it in production in 2010 before a worse thing made it into the language and in 2019 after.
- lilactown 6y agoI would prefer more languages provided delimited continuations, rather than “full” continuations like call/cc. See this paper by Oleg Okmij: http://okmij.org/ftp/continuations/against-callcc.html http://okmij.org/ftp/continuations/against-callcc.html
- anonymoushn 6y agoI would prefer more languages provided copyable coroutines, because I would rather explain create+switch+copy to people than call/cc or shift+reset