2 ms·
Despite call/cc being generally understood as not good it's still something you would expect to work in a Scheme implementation. In the Scheme-on-Wasm implement
by davexunit 1y ago
Despite call/cc being generally understood as not good it's still something you would expect to work in a Scheme implementation. In the Scheme-on-Wasm implementation I work on we emulate call/cc in terms of delimited continuations. Passes r7rs benchmaks that make use of call/cc.
Seems kind of backwards to call them resumable exceptions because delimited continuations are the primitive upon which an exception system can be built but yeah maybe it would make sense to programmers that already understand exceptions. I like the prompt metaphor, myself. https://www.gnu.org/software/guile/manual/html_node/Prompts.html https://www.gnu.org/software/guile/manual/html_node/Prompts....
- matheusmoreira 1y ago> we emulate call/cc in terms of delimited continuations Seems reasonable. > I like the prompt metaphor, myself Me too. I really like Guile's prompts. They are delimited and structurally similar to my example above, only they're even more powerful since they have tags which lets programmers unwind to specific delimiters! I'm implementing this stuff in my lisp right now. The prompt primitive pushes a special continuation marker stack frame which also contains a value. The tagged prompts use symbols as the tag, untagged prompts use nil. > Seems kind of backwards to call them resumable exceptions This is is the analogy that enabled me to finally understand this continuation stuff. Alexis King's keynote shows that they are equivalent: https://youtu.be/TE48LsgVlIU https://youtu.be/TE48LsgVlIU Everybody understands exceptions. Delimited continuations are exceptions that not only unwind the stack but also back it up into a callable value.