PLQ #3Done on:   Tuesday, January 28th

Question 1 @ 2025-01-28 18:29

Recall the following bit of code (discussed in HW#2):

(f (inst rest Number) '(1 2 3))

What is the purpose of inst there?


Question 2 @ 2025-01-28 18:31

How many identifiers do we have in this Racket expression:

(let ([x 1] [y 2])
  (let ([x y] [y x])
    (list 'x= x 'y= y)))

(Reminder: each identifier comes from one binding instance, and is associated with a scope.)


0..8

Question 3 @ 2025-01-28 18:33

Reminder: this is part of the WAE evaluator code that we saw in class, similar to the AE one:

(define (eval expr)
  (cases expr
    ...
    [(Add l r) (+ (eval l) (eval r))]
    [(Sub l r) (- (eval l) (eval r))]
    ...))

Last week, we saw that this doesn’t implement an eager language in itself, it just “inherits” Racket’s behavior (eagerness). There were several similar inherited (“embedded”) features, like having unlimited integers, or exact rationals.

How about the arity of the addition operator in this language, what is its arity?


Question 4 @ 2025-01-28 18:35

Reminder: this is part of the WAE evaluator code that we saw in class, similar to the AE one:

(define (eval expr)
  (cases expr
    ...
    [(Add l r) (+ (eval l) (eval r))]
    [(Sub l r) (- (eval l) (eval r))]
    ...))

Last week, we saw that this doesn’t implement an eager language in itself, it just “inherits” Racket’s behavior (eagerness). There were several similar inherited (“embedded”) features, like having unlimited integers, or exact rationals.

How about the direction of evaluating arguments of an operator: do we implement this, or inherit it from Racket?


Question 5 @ 2025-01-28 18:37

Which of the following WAE evaluations would lead to an unbound identifier error? (In other words: which of these have free identifiers?)


Question 6 @ 2025-01-28 18:39

These were the options in the previous question:

What would change if we did the cheap laziness trick, where we implement lazy evaluation via

(define (eval expr)
  (cases expr
    ...
    [(With bound-id named-expr bound-body)
    (eval (subst bound-body
                  bound-id
                  named-expr))])) ; <-- no eval!