How many identifiers do we have in this Racket expression:
(Reminder: each identifier comes from one binding instance, and is associated with a scope.)
Possible answers were 0…7.
Reminder: this is the AE evaluator code that we saw in class:
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?
eval
takes in one argument.+
is binary+
can take any number of inputsWhich 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}
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?
8
-6
3
-3