A final exam is only partially a learning exercise; it is mostly an assessment tool to clarify what you have learned over the course of the quarter. Therefore, you should do this assignment entirely on your own, using only the textbooks (Programming Languages and Learn You a Haskell), your own written work (notes, problem sets, and your presentation), and your own understanding. The only exception to this rule is that you may refer back to the sources you used for your presentation in answering Question 3, citing them as appropriate. (You should also cite the textbooks as appropriate, at least informally -- e.g., "Sebesta, pp. 277-279".)
You may not talk to other students in the class about the exam.
testAdd2 = addToEnv "fib0" (addToEnv "n" [])) testResults = [ addToEnv "fib1" testAdd2, setVarValue "fib0" 0 testAdd2 ]
testAdd2 = addToEnv("fib0", addToEnv("n", emptyEnv)); testResults[0] = addToEnv("fib1", testAdd2); testResults[1] = setVarValue("fib0", 0, testAdd2);
Assume that in both cases addToEnv
and setVarValue
are
functions to add an uninitialized variable to an environment and set the value
of a variable in
an environment, respectively, where an environment is a list of variable name-value
pairs as in our Jay interpreter program. Both
functions return an environment. Assume
further that emptyList
, testAdd2
, and testResults
have
all been declared and initialized appropriately in the Java code segment. Note
that the Java testResults
variable is an array of environments,
each of which represents the result of a particular test case.
Thesis: These two code segments appear to be very similar, with minor syntactic differences. This similarity is, however, misleading; the semantic differences go much deeper than the syntactic ones.
Assignment: Justify the thesis above, focusing on the role and type
of testAdd2
in each code segment, and how that impacts each line of code in
the two examples.
object-oriented = objects + object classes + class inheritanceWe might also write this as:
object-oriented = encapslation + user-defined types + class inheritance