PLQ #11Done on:   Tuesday, April 12th

Question 1 @ 2022-04-12 19:20

Which one of the following is NOT a side effect?


Question 2 @ 2022-04-12 19:23

Last week, and in the homework, we discussed implementing side effects in a lazy language. Say that we want to add the ability to read a line with a given prompt — we’ll want to extend the IO type

(define-type IO
  [Print      String]
  [ReadLine  (String -> IO)]
  [ReadPrompt ???]          ; <===
  [Begin2    IO IO])

What should the ReadPrompt type be?


Question 3 @ 2022-04-12 19:26

(define (and-fun expr1 expr2)
  (if expr1 expr2 #f))

(define-macro (and-macro <expr1> <expr2>)
  `(if ,<expr1> ,<expr2> #f))

Which statement about the above definitions is the most accurate?


Question 4 @ 2022-04-12 19:33

The following macro definition is an attempt to implement a runtime debugging utility:

(define-macro (debug expr)
  (printf "Evaluating: ~s\n" expr)
  `(let ([result ,expr])
    (printf "Result: ~s\n" result)
    result))

How is it broken?