PLQ #10Done on: Tuesday, April 5th
Question 1 @ 2022-04-05 18:37
Which of the following tools did we use to implement our lazy
- Expression closures
- Tail call optimization
- Conditional evaluation
Question 2 @ 2022-04-05 18:39
If the following code is executed in our Lazy Racket language, what is
the result? (In this example «E₁» and «E₂» are placeholders for some
(if (list «E₁» (* 3 (/ 4 0)) «E₂»)
- An error; the program crashes with a division by zero
- An error; the program crashes because a list is given as the
condition of ‘if’
- Cannot answer this without knowing what is «E₁».
- Cannot answer this without knowing what is «E₂».
Question 3 @ 2022-04-05 18:42
What problem in our Sloth implementation does the
- It allows constructing infinite lists.
- It enables infinite loops.
- It ensures that only
RktVs are returned from the
- It handles cases where evaluating an
ExprV results in an
- It creates a new closure of an
ExprV and a given environment.
- Strict does not solve any particular problem, it makes the code
run more efficiently.
- Strict does not solve any particular problem, it’s just a
Question 4 @ 2022-04-05 18:45
As we’ve seen last week, generators and channels give programmers a
more expressive control flow constructs. Which of the following
statements explains why this works?
- They use call-by-reference to delay evaluation.
- They execute code lazily, similarly to a real lazy language.
- They can be used to implement control flows that are different
from the standard call-a-function-and-get-an-answer.
- They provide a better implementation of short-circuit
- They are eagerly evaluated when called.
- They cannot be partially evaluated.
Question 5 @ 2022-04-05 18:48
Last week we went over our new Sloth language and its implementation of
laziness, which of the following statements are true?
- Unlike the previous languages we learned, dynamic scoping is
preferred in a lazy language over a strict language.
- There is an issue similar to dynamic scope when evaluating
delayed computations, which was solved in a similar way to our
implementation of lexical scope.
- Lazy languages benefit from static typing as implemented in
- Lazy languages benefit from substitution caches as implemented
- Every function call must be delayed in Sloth.
- Sloth uses the substitution model to preserve lexical scope.
- Lazy code cannot be compiled, as is the case with
Question 6 @ 2022-04-05 18:51