4 ms·
Pointers being symmetric was the point of his analogy. The asymmetry shows up when the setter is pure, returning a new version of the record instead of mutatin
by ufo 12y ago
Pointers being symmetric was the point of his analogy. The asymmetry shows up when the setter is pure, returning a new version of the record instead of mutating it (as is the case in Haskell).
A getter is simple:
x = s.foo.bar;
As is an impure setter:
s.foo.bar = y;
But a non-mutating setter is a bit more work:
Foo foo2 = s.foo;
foo2.bar = y;
S s2 = s;
s2.foo = foo2;