Question 1 @ 2024-10-08 18:25
Which of the following are true about different treatments of functions in programming languages?
-
First order: functions can be used as values
-
First order: function values can be created in any scope
-
Higher order: functions can be used as values
-
Higher order: function values can be created in any scope
-
First class: functions can be used as values
-
First class: function values can be created in any scope
Question 2 @ 2024-10-08 18:28
What expressions are in the scope of the first y
in this expression:
{with {y E2} <--- this guy
{with {z E3}
{with {y E4}
E5}}}}
-
The question is bogus, we cannot distinguish just the first
y
. - E1
- E2
- E3
- E4
- E5
Question 3 @ 2024-10-08 18:30
What is the result of the following Interactive Falsification (IF) expression from HW#4?
{with {y {if x False True}}
y}}
1
False}
-
Error: You cannot have a
with
expression inside an `if’ -
Error: The there is a free
x
identifier -
Error: The there is a free
y
identifier -
#t
-
#f
-
1
Question 4 @ 2024-10-08 18:34
At some point we had the following broken bit of code in our
implementation of subst
:
(cases expr
...
[(With bound-id named-expr bound-body)
(if (eq? bound-id from)
expr
(With bound-id
(subst named-expr from to)
(subst bound-body from to)))]))
Which one of the following tests can be used to demonstrate the bug in this code fragment?
-
{with {x x} ...}
-
{with {x x} {with {x 3} ...}}
-
{with {x 3} {with {x x} ...}}
-
{with {x 3} {with {y x} ...}}
-
{with {y 3} {with {x y} ...}}
Question 5 @ 2024-10-08 18:38
What are we going to do today?
-
Optimize our language using native-code compilation.
-
Improve our asymptotically horrible function call costs.
-
Implement third-order functions.
-
Implement object orientedness in our language.
-
Add a type checker.