## Question 1 @ 2023-01-31 18:06

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.)

## Question 2 @ 2023-01-31 18:10

Reminder: this is the AE evaluator code that we saw in class:

(define (eval expr)
(cases expr
[(Num n)  n]
[(Add l r) (+ (eval l) (eval r))]
[(Sub l r) (- (eval l) (eval r))]
[(Mul l r) (* (eval l) (eval r))]
[(Div 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 eagerness. There were several similar inherited (“embedded”) features, like having unlimited integers, or like not implementing left-to-right (the language has both, which is because Racket has these numbers and evaluates LtR).

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

1. Trick question: there is a bug in this code
2. Unary, because `eval` takes in one argument.
3. Binary, because Racket’s `+` is binary
4. Binary, because of the AE BNF & data type
5. Variable-arity, because Racket’s `+` can take any number of inputs
6. Whatever Racket does

## Question 3 @ 2023-01-31 18:13

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

• `{with {x x} 1}`
• `{with {x x} x}`
• `{with {x 1} {with {x x} x}}`
• `{with {x {with {x 1} x}} x}`

## Question 4 @ 2023-01-31 18:16

As we considered how should substitution be formalized, we had the following (bad!) definition on the way to the correct one:

e[v/i]: To substitute an identifier i in an expression e with an expression v, replace all instances of i that are not themselves binding instances with the expression v

If we used this definition, what would the following evaluate to?

{with {x 2}
{- x {with {x 5}
{with {y 3}
{+ x y}}}}}

• `8`
• `-6`
• `3`
• `-3`
• Nothing, since we’d get a runtime error
• Nothing, since we’d get nonsensical syntax