# PLQ #4Done on:   Tuesday, October 20th

## Question 1 @ 2020-10-20 18:31

What environment diagram do we get when we evaluate the following Racket code:

(define counter
(let ([n 0])
(lambda ()
n)))

?

## Question 2 @ 2020-10-20 18:43

For the same code,

(define counter
(let ([n 0])
(lambda ()
n)))

what can we learn about Racket when we try this expression:

(list (counter) (counter) (counter) (counter))

?

(Remember to choose the best answer!)

1. We can learn whether Racket uses eager evaluation or lazy.
2. We can learn whether Racket evaluates its arguments left-to-right or right-to-left.
3. We can learn whether Racket is compiled or interpreted.
4. We can learn whether Racket is dynamically-scoped or lexically-scoped.
5. We can learn whether Racket uses dynamic type-checking or static type-checking.

## Question 3 @ 2020-10-20 18:49

Still for the same code, with the experimental expression:

(define counter
(let ([n 0])
(lambda ()
n)))

(list (counter) (counter) (counter) (counter))

what would we get if Racket had been dynamically scoped?

1. We would get an error about unbound `counter`.
2. We would get an error about unbound `n`.
3. We would get an error about a bad type for `counter`.
4. We would get the list ’(0 0 0 0)
5. We would get the list ’(1 1 1 1)
6. We would get the list ’(1 2 3 4)

## Question 4 @ 2020-10-20 19:20

For a variation of that code:

(define counter
(lambda ()
(let ([n 0])
(lambda ()
n))))

(define c1 (counter))
(define c2 (counter))

What would we get from the following experiment

(list (counter) (c1) (c2) (c1) (c1) (c2))

?

1. Type error because of the (counter) bit
2. It would result in a list similar to: (list (error) 1 1 2 3 2)
3. It would result in a list similar to: (list #procedure:blah 1 1 2 3 2)
4. It would result in a list similar to: (list (error) 1 2 1 1 2)
5. It would result in a list similar to: (list #procedure:blah 1 2 1 1 2)