PLQ #8Done on:   Tuesday, March 22nd

Question 1 @ 2022-03-22 18:51

In the new “Toy” language that we briefly discussed, what is the evaluation of the following snippet of code?

{bind {{/ -}} {/ 2 0}}

Question 2 @ 2022-03-22 18:59

Which of the following changes are made in the Toy language, relative to the Flang language?


Question 3 @ 2022-03-22 19:02

Now that we have side effects including mutable boxes, we are able to implement objects with state. Which of the following is true about the object below?

(define (make-counter x)
  (let ([xb (box x)])
    (lambda (msg)
      (match msg
        ['getx (unbox xb)]
        ['incx (set-box! xb (add1 (unbox xb)))
              (update-screen)]))))

Question 4 @ 2022-03-22 19:06

In our “OOP-like” example (repeated below), can we have recursive methods? What about “static members” — methods and variables?

(define (make-counter x)
  (let ([xb (box x)])
    (lambda (msg)
      (match msg
        ['getx (unbox xb)]
        ['incx (set-box! xb (add1 (unbox xb)))
              (update-screen)]))))

Question 5 @ 2022-03-22 19:10

What is the main difference between a compiler and the curried TOY eval function?