From: Sean O'Dell Date: 2004-07-10T06:30:07+09:00 Subject: Re: Functional Ruby (Re: Why I don't use Ruby.) On Friday 09 July 2004 13:37, Lennon Day-Reynolds wrote: > Ruby objects are mutable in the sense that you can do the following: > > a = [] > a.add(1) > > The internal state of 'a' has been changed, which is a no-no in > functional languages. Of course, most of them do so anyway for tasks > like I/O, and use some sort of abstraction (which often looks eerily > like an 'object') to hide those side-effects from the programmer. You can modify values, as long as the value isn't a global (stateful data). The key is that the function has to represent the modification, so that when you call it with a given set of values, it always does the same thing. You can say: function a = array add(a, 1) end ...because anytime you call add, it does the same thing to the array you give it, and your function always does the same thing. But you can't do this: $a = array function add($a, 1) end ...because your function now uses a variable which can be modified by other functions, so if you called function more than once, it's possible to get two different results. Functional programming doesn't allow this, and this is really, I think, the very heart of functional programming. Sean O'Dell