comment on handout/alias/let
authorJim Pryor <profjim@jimpryor.net>
Tue, 23 Nov 2010 00:56:51 +0000 (19:56 -0500)
committerJim Pryor <profjim@jimpryor.net>
Tue, 23 Nov 2010 00:56:51 +0000 (19:56 -0500)
Signed-off-by: Jim Pryor <profjim@jimpryor.net>
week9.mdwn

index d659e75..a44018a 100644 (file)
@@ -429,6 +429,8 @@ Here's how to implement these. We'll suppose that our assignment function is lis
                        (* evaluate expr2 using original assignment function and new store *)
                        in eval expr2 g s''
 
+Note: Chris uses this kind of machinery on the third page of the Nov 22 handout. Except he doesn't implement `Change`, and he adds an implementation of `Alias` (see below). Some minor differences: on his handout (and following Groenendijk, Stockhof and Veltman), he uses `r` and `g` where we use `g` and `s` respectively. Also, he implements his `r` with a function from `char` to `int`, instead of a `(char * int) list`, as we do here. It should be obvious how to translate between these. Finally, and this is somewhat more substantial: he implements `Let(c, expr1, expr2)` not by allocating a new peg for `c` as we do above, but rather by changing the value stored at the peg that his `r` already associates with `c`. Without aliases, it doesn't matter which way you go. With aliases, his method is the way to go, because then all other variables aliased to the same peg will automatically inherit the new value. However, his solution requires that variables always already have an associated peg. So that when we call `Let(c, expr1, expr2)` for the first time with `c`, there's a peg whose value is to be updated. That's easier to ensure when you implement the assignment as a function than as a `(char * int) list`.
+
 
 ##How to implement mutation with a State monad##