Merge branch 'pryor'
[lambda.git] / week9.mdwn
index f854d27..a0c8432 100644 (file)
@@ -217,6 +217,8 @@ At the end, we'll get `(1, 2, 3)`. The reference cell that gets updated when we
 
 Here, too, just as in the OCaml fragment, all the calls to getter and setter are working with a single mutable variable `free_var`.
 
+If you've got a copy of *The Seasoned Schemer*, which we recommended for the seminar, see the discussion at pp. 91-118 and 127-137.
+
 If however you called `factory` twice, you'd have different `getter`/`setter` pairs, each of which had their own, independent `free_var`. In OCaml:
 
        let factory (starting_val : int) =
@@ -228,8 +230,6 @@ If however you called `factory` twice, you'd have different `getter`/`setter` pa
 
 Here, the call to `setter` only mutated the reference cell associated with the `getter`/`setter` pair. The reference cell associated with `getter'` hasn't changed, and so `getter' ()` will still evaluate to 1.
 
-If you've got a copy of *The Seasoned Schemer*, which we recommended for the seminar, see the discussion at pp. 91-117 and 127-137.
-
 Notice in these fragments that once we return from inside the call to `factory`, the `free_var` mutable variable is no longer accessible, except through the helper functions `getter` and `setter` that we've provided. This is another way in which a thunk like `getter` can be useful: it still has access to the `free_var` reference cell that was created when it was, because its free variables are interpreted relative to the context in which `getter` was built, even if that context is otherwise no longer accessible. What `getter ()` evaluates to, however, will very much depend on *when* we evaluate it---in particular, it will depend on which calls to the corresponding `setter` were evaluated first.
 
 ##Referential opacity##
@@ -696,7 +696,7 @@ Programming languages tend to provide a bunch of mutation-related capabilities a
                in let (adder', setter') = factory 1
                in ...
 
-       Of course, in most languages you wouldn't be able to evaluate a comparison like `getter = getter'`, because in general the question whether two functions always return the same values for the same arguments is not decidable. So typically languages don't even try to answer that question. However, it would still be true that `getter` and `getter'` (and `adder` and `adder'`) were extensionally equivalent.
+       Of course, in most languages you wouldn't be able to evaluate a comparison like `getter = getter'`, because in general the question whether two functions always return the same values for the same arguments is not decidable. So typically languages don't even try to answer that question. However, it would still be true that `getter` and `getter'` (and `adder` and `adder'`) were extensionally equivalent; you just wouldn't be able to establish so.
 
        However, they're not numerically identical, because by calling `setter 2` (but not calling `setter' 2`) we can mutate the function value `getter` (and `adder`) so that it's *no longer* qualitatively indiscernible from `getter'` (or `adder'`).