Computers and Technology
an obvious way to extend our arithmetic expressions is by also allowing the declaration of variables with immediately assigning a value computed by an expression. this type of expression is commonly referred to as let-expression. so we have additionally: syntax: a let-expression is a tuple let(x y z) where x is an atom giving the variable name and y and z are expressions. semantics: the first expression inside a let-expression defines the value to be assigned to the variable introduced in the let-expression. the second expression can refer to the variable introduced. in some sense, a let-expression is similar with a local statement, except the fact that the former returns the value of an expression, whereas the latter is a statement (it just does some computations). example: {eval let(x mult(int(2) int(4)) add(var(x) int(3))) env} should return 11. the variable x will be bound to the value of the expression mult(int(2) int(4)), which is evaluated to 8. after that, the second expression, add(var(x) int(3)), is evaluated to 8 3, and its result, 11, is returned. hints: one needs environment adjunction as well here which is implemented by record adjunction. the mozart system provides a specific function for adding features and values to the records, namely: {adjoinat r f x} takes a record r, a feature f, and a new field x and returns a record which has a feature f with the value x in addition to all features and fields from r except f. examples: (of using adjoinat) {adjoinat a(x:1 y:2) z 7} returns a(x:1 y:2 z:7) {adjoinat a(x:1 y:2) x 7} returns a(x:7 y:2) write an oz program considering let-expressions (extending the previous expression evaluators from past homeworks).