Reminds me of an HWN quote from a few weeks back.<br><br>Jan 9, 2007 HWN<br>"<em>Paul Johnson</em>: Mutable state is actually another form of manual
memory management: every time you over-write a value you are making a
decision that the old value is now garbage, regardless of what other part of
the program might have been using it."<br><br><div><span class="gmail_quote">On 1/31/07, <b class="gmail_sendername">Doaitse Swierstra</b> <<a href="mailto:doaitse@cs.uu.nl">doaitse@cs.uu.nl</a>> wrote:</span>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">If you ask an "ordinary" programmer what is the effect of an<br>assignment like:<br>
<br>x := <expr><br><br>you will get an answer along the lines: the <expr> is evaluated and<br>the result is stored in a box named "x".<br><br>If you ask him/her whether something else has happened the answer
<br>will usually be "no"; and this is the wrong answer, since one tends<br>to overlook the fact that one has, by mentioning the variable "x",<br>also indicated that the old value of "x" is no longer needed. As such
<br>imperative programming is "functional programming with explicit<br>garbage collection".<br><br>This may have been a necessity in the old days, when memory was<br>scarce and machines slow (in my first course on numeric algorithms we
<br>were taught to declare the variables x, y, z, n, m, i, and j, and the<br>array a, and to solve our problems with those only; points would be<br>deducted for making use of more variables, or not reusing whenever<br>possible!). Nowadays I think everyone agrees that automatic garbage
<br>collection is a good thing; think about the amount of wasted<br>programmer years of people figuring out where they have space leak,<br>etc., and users of programs getting a disappointing feeling about<br>computer science as a whole since apparently we keep delivering
<br>programs that stop to work at unpredictable moments.<br><br>So, one might wonder whether assignments are always bad, bringing us<br>back to the OO discussion. Of course if we have the following<br>expression:<br><br>
digest.chew.eat.serve.cook.chop.pluck.kill $ chicken<br><br>we all have a definite feeling that after applying the functions, the<br>original object is no longer available, and the FP view does not feel<br>entirely natural.
<br><br> Doaitse Swierstra<br><br><br><br><br><br><br>_______________________________________________<br>Haskell-Cafe mailing list<br><a href="mailto:Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a><br><a href="http://www.haskell.org/mailman/listinfo/haskell-cafe">
http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br></blockquote></div><br>