Take the following WAE expression:

\v/

{with {x x} x}

/^\

{with {x x} x}

/^\

Which kind of an identifier is the FIRST occurrence of `x`

?

- Binding.
- Bound.
- Free.
- Lazy.
- Eager.

Take the following WAE expression:

\v/

{with {x x} x}

/^\

{with {x x} x}

/^\

Which kind of an identifier is the SECOND occurrence of `x`

?

- Binding.
- Bound.
- Free.
- Lazy.
- Eager.

Take the following WAE expression:

\v/

{with {x x} x}

/^\

{with {x x} x}

/^\

Which kind of an identifier is the THIRD occurrence of `x`

?

- Binding.
- Bound.
- Free.
- Lazy.
- Eager.

The scope of an identifier…

- … is nonsensical, scope is something “of a program”.
- … is a lexical (static) property of code.
- … is a dynamic runtime property of code.
- … cannot be determined without running the code.
- … depends on whether we have an eager or a lazy language implementation.
- … depends on whether the identifier is bound or free.

Last time, we have seen the implementation of the WAE evaluator,
specifically, this was the evaluation fragment for `with`

:

[(With bound-id named-expr bound-body)

(eval (subst bound-body

bound-id

(Num (eval named-expr))))]

(eval (subst bound-body

bound-id

(Num (eval named-expr))))]

We saw that there is a simple way to make it into a lazy binder. How do we do that?

- This is already the lazy implementation!
- Remove the
`eval`

in the last line. - Remove the
`Num`

in the last line. - Remove both the
`Num`

and the`eval`

in the last line. - Add a
`subst`

around the`named-expr`

too. - The actual change needs to be in
`subst`

, which needs to always go into the`named-expr`

part.

Alice has excited about intsets from HW#2, so she wrote some code to find out the length of a (normalized) set:

(: intset-length : INTSET -> Integer)

(define (intset-length set)

(cases set

[(Num n) 1]

[(Range lhs rhs) (+ (- rhs lhs) 1)]

[(2Sets lhs rhs) (+ (intset-length lhs) (intset-length rhs))]))

(define (intset-length set)

(cases set

[(Num n) 1]

[(Range lhs rhs) (+ (- rhs lhs) 1)]

[(2Sets lhs rhs) (+ (intset-length lhs) (intset-length rhs))]))

Bob says that Alice should add an `else`

clause:

[else (error "unexpected intset variant")]

Is this correct?

- No.
- Yes.
- No, adding an
`else`

will essentially remove the advantage we get from the Type checker. - Yes, we need to cover all possible cases. An
`else`

clause will help covering additional cases if the INTSET type gets extended. - No, because adding an
`else`

will cause a type error. - Yes, adding an
`else`

is always a good idea, especially for conditionals in a Typed language.