PLQ #10Done on:   Tuesday, March 25th

Question 1 @ 2025-03-25 18:23

What should the following expression evaluate to in the #lang pl lazy REPL?

(define (loop) (loop))
(if (loop) "foo" x)

Question 2 @ 2025-03-25 18:27

What should the following expression evaluate to in the #lang pl lazy REPL?

(define (loop) (loop))
(if (list (loop)) "foo" x)

Question 3 @ 2025-03-25 18:29

When we talked about the implementation of our Sloth lazy language, we’ve talked about a need for a function that “forces lazy values”:

(: strict : VAL -> VAL)
(define (strict val)
  (cases val
    [(ExprV expr env) (strict (eval expr env))] ; loop back
    [else val]))

When is this function always needed?


Question 4 @ 2025-03-25 18:33

When we talked about the implementation of our Sloth lazy language, we’ve talked about a need for a function that “forces lazy values”:

(: strict : VAL -> VAL)
(define (strict val)
  (cases val
    [(ExprV expr env) (strict (eval expr env))] ; loop back
    [else val]))

When is this function sometimes needed?


Question 5 @ 2025-03-25 18:35

(Warning: possibly difficult question.)

In our Sloth implementation, we implemented if as a builtin part of out evaluator:

[(If cond-expr then-expr else-expr)
(eval* ...)]

We’ve also seen that in #lang pl lazy, if is a function (unlike Racket, where if is a special form).

The question is: must if be provided as a builtin functionality in the language?