week9 tweak
[lambda.git] / week9.mdwn
index b2fbb3a..568fc81 100644 (file)
@@ -304,6 +304,15 @@ For expressions we already know how to interpret, `s'` will usually just be `s`.
                        eval expr2 ((c, value) :: g) s'
                ...
 
                        eval expr2 ((c, value) :: g) s'
                ...
 
+Similarly:
+
+               ...
+               | Addition (expr1, expr2) ->
+                       let (value1, s') = eval expr1 g s
+                       in let (value2, s'') = eval expr2 g s'
+                       in (value1 + value2, s'')
+               ...
+
 Let's consider how to interpet our new syntactic forms `newref`, `deref`, and `setref`:
 
 
 Let's consider how to interpet our new syntactic forms `newref`, `deref`, and `setref`:
 
 
@@ -332,7 +341,7 @@ Let's consider how to interpet our new syntactic forms `newref`, `deref`, and `s
                                in (Index new_index, s'')
                        ... 
 
                                in (Index new_index, s'')
                        ... 
 
-2.     When `expr` evaluates to a `store_index`, then `deref expr` should evaluate to whatever value is at that index in the current store. (If `expr` evaluates to a value of another type, `deref expr` is undefined.) In this operation, we don't change the store at all; we're just reading from it. So we'll return the same store back unchanged.
+2.     When `expr` evaluates to a `store_index`, then `deref expr` should evaluate to whatever value is at that index in the current store. (If `expr` evaluates to a value of another type, `deref expr` is undefined.) In this operation, we don't change the store at all; we're just reading from it. So we'll return the same store back unchanged (assuming it wasn't changed during the evaluation of `expr`).
 
                let rec eval expression g s =
                        match expression with
 
                let rec eval expression g s =
                        match expression with