PLQ #8Done on:   Tuesday, November 5th

Question 1 @ 2024-11-05 18:40

Consider this implementation of a recursive binder:

[(WRec bound-id named-expr bound-body)
(eval bound-body
      (Some-Kind-of-Extend bound-id (eval named-expr env) env))]

What’s wrong with it?


Question 2 @ 2024-11-05 18:43

Say that we enter the following in the Racket REPL:

> (define x (box 'red))
> (define y (box 'green))
> (set-box! x (set-box! y 'blue))
> (unbox x)

What is the result of the last expression?


Question 3 @ 2024-11-05 18:45

Say that we enter the following in the Racket REPL:

> (define x (box #f))
> (define y (box #f))
> (set-box! x (set-box! y x))

Does this result in a cyclic structure?

(Reminder: choose the best answer!)


Question 4 @ 2024-11-05 18:49

Say that you’re working in a REPL of a Racket-like language, and you have a box value in x:

(define x (box 1))

Consider the following expression:

(list (set-box! x (add1 (unbox x)))
      (unbox x))

Based on the result of this expression, you’ll be able to tell whether the language:


Question 5 @ 2024-11-05 18:52

During some random REPL-based hacking of a web page, I entered:

setInterval(() => f(), 1000)

What could be a reason that I used () => f() rather than just f?

Notes:

(Keep in mind that this is in the full Javascript language, equivalent to the full Racket language.)