Closed martin-henz closed 2 months ago
Good to see that https://github.com/source-academy/js-slang/pull/1687 implements a version that captures both specifi cases. The generalizations that I mentioned need a bit more thought. Let's keep this issue open, to serve as inspiration later.
Consider:
The env instructions are not needed because there are only * instructions on control. More generally, an env instruction can be avoided if there are no statements or expressions on the control from the top of the control stack until the next env instruction. "Statements or expressions" includes instructions that have statements or expressions inside, such as branch instructions.
We should also avoid environment instructions when the environment does not change: application of nullary function that is declared in the current environment.
The pedagogical strategy is to introduce "complications" such as env instructions only when needed. Simple programs have simple explanations and complex programs may require more complex explanations.