3 ms·
Seems to me this post is based on a misunderstanding of the Alan Kay quote. Kay wanted to minimize the role of _assignment_, not mutability. So instead of say
by nycticorax 16y ago
Seems to me this post is based on a misunderstanding of the Alan Kay quote. Kay wanted to minimize the role of _assignment_, not mutability. So instead of saying things like a=f(a), you say a.f(), where the method f simply mutates a in place. At least, that's how it sounds to me.
- jsvaughan 16y agoI completely agree. Kay is criticising developers whose code breaks encapsulation. Has nothing to do with mutability.
- davidmathers 16y agoYes exactly. With the caveat that f should be a meaningful procedure that does some real work, not direct state manipulation. The OP is kind of ridiculous actually.
- cwp 16y agoAssignment and mutability aren't quite the same thing, but they're pretty close. If a.f() has the effect of mutating the internal state of a, how does that occur? By assignment! In Smalltalk, there's a fairly common pattern of immutable objects. Their state is set when the object is created and then never changed. There might be getter methods, but there are no setters, and in fact the only method that makes assignments to instance variables is the initializer. It's not hard to see how that could be extended from "fairly common" to being a fundamental part of the language.
- loup-vaillant 16y agoI think you misunderstood the quote. Specifically, "even if presented figuratively", and "Many programs are loaded with “assignment-style” operations now done by more expensive attached procedures". Setters are assignment-style operations, and a.f() is an attached procedure. Also, in http://www.c2.com/cgi/wiki?AlanKayOnMessaging http://www.c2.com/cgi/wiki?AlanKayOnMessaging you can see "[I realized] that assignments are a metalevel change from functions, and therefore should not be dealt with at the same level - this was one of the motivations to encapsulate these kinds of state changes, and not let them be done willy nilly" Alan Kay really is for segregating mutable state.