From 9ce764c80ac52df9f506064a66a82eefdfd26c92 Mon Sep 17 00:00:00 2001 From: Jim Pryor Date: Sun, 21 Nov 2010 22:42:42 -0500 Subject: [PATCH 1/1] week9 tweak Signed-off-by: Jim Pryor --- week9.mdwn | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/week9.mdwn b/week9.mdwn index 2e80250e..363b5d94 100644 --- a/week9.mdwn +++ b/week9.mdwn @@ -326,7 +326,7 @@ Similarly: Let's consider how to interpet our new syntactic forms `newref`, `deref`, and `setref`: -1. \[[newref starting_val]] should allocate a new reference cell in the store and insert `starting_val` into that cell. It should return some "key" or "index" or "pointer" to the newly created reference cell, so that we can do things like: +1. **newref starting_val** should allocate a new reference cell in the store and insert `starting_val` into that cell. It should return some "key" or "index" or "pointer" to the newly created reference cell, so that we can do things like: let ycell = newref 1 in ... @@ -351,7 +351,7 @@ Let's consider how to interpet our new syntactic forms `newref`, `deref`, and `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 (assuming it wasn't changed during the evaluation of `expr`). +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 @@ -362,7 +362,7 @@ Let's consider how to interpet our new syntactic forms `newref`, `deref`, and `s in (List.nth s' n, s') ... -3. When `expr1` evaluates to a `store_index` and `expr2` evaluates to an `int`, then `setref expr1 expr2` should have the effect of changing the store so that the reference cell at that index now contains that `int`. We have to make a decision about what value the `setref ...` call should itself evaluate to; OCaml makes this `()` but other choices are also possible. Here I'll just suppose we've got some appropriate value in the variable `dummy`. +3. When `expr1` evaluates to a `store_index` and `expr2` evaluates to an `int`, then **setref expr1 expr2** should have the effect of changing the store so that the reference cell at that index now contains that `int`. We have to make a decision about what value the `setref ...` call should itself evaluate to; OCaml makes this `()` but other choices are also possible. Here I'll just suppose we've got some appropriate value in the variable `dummy`. let rec eval expression g s = match expression with -- 2.11.0