16 Written: Control

These are due by midnight on Friday, May 1.

CPS


Stack Space and CPS

Any program that consumes some amount of stack, when converted to CPS and run, consumes no stack space at all. Why?

Update: Two clarifications. (1) This assumes that closures are allocated in the store, and (2) if it aids your understanding, consider the question with “no stack space at all” replaced with “a small constant amount of stack space.”

As a corollary, does conversion to CPS reduce the overall memory needed to run the program? Why or why not?


Efficient Exceptions

Consider this stack-based interpreter:

https://code.pyret.org/editor#share=0B32bNEogmncOY3ExdmNlRThDTnc&v=v0.5r852