From: Jim Weirich Date: 2004-07-14T11:53:48+09:00 Subject: Re: Functional Ruby (Re: Why I don't use Ruby.) I see elsewhere in this thread you found a functional primer that may resolve some of these issues. I'll just respond to one thing here ... Sean O'Dell wrote: > On Tuesday 13 July 2004 14:31, Jim Weirich wrote: >>One of the benefits of functional languages is the ability to do >>algebraic-like manipulations of the source code ... kinda like provably >>correct refactorings. For example, given X=12, within the scope of X I >>can replace all occurances of X with the value 12 (or the reverse, replace >>all occurances of 12 with X). If X is sometimes 12 and sometimes 13, then >>the substitution is no longer valid anywhere in the scope of X. That is >>why even local variables are immutable in a "pure" functional language. > > But this is more of an implementation feature. [...] > You could make C's variables totally immutable and > pre-process C code in the same way. It's a feature that's easy to do with > functional languages, but I don't think truly at the heart of them. Having > mutable, local variables in a functional language disables such features, but > the language is still a functional one. John Backus's 1977 Turing Award speech was entitled "Can Programming Be Liberated from the von Neumann Style? A Functional Style and Its Algebra of Programs". Even in the title of the speech emphasized the ability to meaningfully manipulate and transform programs. This is hardly an "implementation detail" of functional languages. It is why computer scientists were interested in functional languages in the first place. Quoting from the abstract: "Associated with the functional style of programming is an algebra of programs whose variables range over programs and whose operations are combining forms. This algebra can be used to transform programs and to solve equations whose "unknowns" are programs in much the same way one transforms equations in high school algebra. These transformations are given by algebraic laws and are carried out in the same language in which programs are written. Combining forms are chosen not only for their programming power but also for the power of their associated algebraic laws. General theorems of the algebra give the detailed behavior and termination conditions for large classes of programs." -- -- Jim Weirich jim@weirichhouse.org http://onestepback.org ----------------------------------------------------------------- "Beware of bugs in the above code; I have only proved it correct, not tried it." -- Donald Knuth (in a memo to Peter van Emde Boas)