Question 1 @ 2025-04-15 21:29
Given that CPS (continuation passing style) is fundamentally about control flow, what are the difficulties/problems that are inherent to it.
Choose the only WRONG answer.
-
Compilation of CPS-ed code is impossible since it depends on execution order.
-
We mangle the lexical code to follow the dynamic control flow, which is a mess.
-
The translation is a global one, which means that
*/k
is spreading across all function calls, including code that is not ours. -
Keeping track of which expressions have a “future value” (a promise in JS lingo) and which aren’t is very difficult.
Question 2 @ 2025-04-15 21:32
What can we say about the CPS process?
(Choose the best answer.)
-
It needs to be done selectively: locally in places that require IO.
-
It needs to be done globally, CPS-ing a function forces all its callers to be CPS-ed as well.
-
It needs to be guided by IO types similar to the Slug types.
-
It requires the original code to be functional code, and cannot work on imperative code.
Question 3 @ 2025-04-15 21:34
What are features of CPS-ed code?
(Choose all features that are relevant.)
- All calls are tail calls.
- It cannot be statically typed.
- It can only be dynamically typed.
- It cannot allocate new heap space.
- It does not consume any stack space.
- It never returns values, only passes values onto continuations.
- It is sequentialized, meaning that evaluation order is fixed.
- It can speed up computation due to tail call optimization.