Written: Laziness

Question 1: Laziness and State

Lazy languages usually don't have stateful operations such as mutating values in boxes, or assigning values to variables. Why not?

The best answer would include two things: a short program (which we assume will evaluate in a lazy regime) that uses state, and a brief explanation of what problem the execution of this program illustrates. Please be sure to use the non-caching notion of laziness. If you present a sufficiently illustrative example (which needn't be very long!), your explanation can be quite short indeed.

Question 2: Type Checking

Earlier in the semester, you wrote a type checker for a strict language. It handled the following kinds of expressions:

id, 
boolean, if,
num, +, num=, 
link, first, rest, is-empty, empty, 
lam, let, apply
Consider what you would need to do to update your type checker for a lazy language. Which of these kinds of expressions would need to be handled differently? Be specific, ideally with relevant code fragments.

Question 3: Strictness

In our lazy interpreter, we identified several strictness points. One of our sedentary students is rather taken with the idea of laziness; he suggests we can get away with only one strictness point, at the point of looking up identifiers.

Is it possible to write a program that will produce different results under the original interpreter and this modified one? You should answer this question for two languages:

  1. The first language supports arithmetic, first-class functions, recursive functions, and conditionals.
  2. The second language supports all of the features of the first language, and also supports lists.

You could, if you wanted, implement these features in an interpreter and produce those, with input programs, to justify your answer. However, you can also describe their behavior without having to implement them. Your choice.

Submit at this link:

https://www.captain-teach.org/brown-cs173/assignments/