week9 tweak
authorJim Pryor <profjim@jimpryor.net>
Sun, 21 Nov 2010 20:18:32 +0000 (15:18 -0500)
committerJim Pryor <profjim@jimpryor.net>
Sun, 21 Nov 2010 20:18:32 +0000 (15:18 -0500)
Signed-off-by: Jim Pryor <profjim@jimpryor.net>
week9.mdwn

index 00900ea..9c886b0 100644 (file)
@@ -100,6 +100,8 @@ Scheme is similar. There are various sorts of reference cells available in Schem
                (set-box! ycell 3)
                (+ x (unbox ycell)))
 
                (set-box! ycell 3)
                (+ x (unbox ycell)))
 
+(C has explicit-style mutable variables, too, which it calls *pointers*. But simple variables in C are already mutable, in the implicit style.)
+
 When dealing with explicit-style mutation, there's a difference between the types and values of `ycell` and `!ycell` (or `(unbox ycell)`). The former has the type `int ref`: the variable `ycell` is assigned a reference cell that contains an `int`. The latter has the type `int`, and has whatever value is now stored in the relevant reference cell. In an implicit-style framework though, we only have the resources to refer to the contents of the relevant reference cell. `y` in fragment [G] or the C snippet above has the type `int`, and only ever evaluates to `int` values.
 
 
 When dealing with explicit-style mutation, there's a difference between the types and values of `ycell` and `!ycell` (or `(unbox ycell)`). The former has the type `int ref`: the variable `ycell` is assigned a reference cell that contains an `int`. The latter has the type `int`, and has whatever value is now stored in the relevant reference cell. In an implicit-style framework though, we only have the resources to refer to the contents of the relevant reference cell. `y` in fragment [G] or the C snippet above has the type `int`, and only ever evaluates to `int` values.