From: Joel VanderWerf Date: 2004-07-09T04:08:37+09:00 Subject: Re: Functional Ruby (Re: Why I don't use Ruby.) Sean Russell wrote: > Mikael Brockman wrote in message news:<87llhx2hec.fsf@phubuh.org>... > >>You're mistaken in believing that functional programs must lack method >>calls. Scheme's CAR and CDR are just as `object-oriented' as Ruby's >>first and tail. Ruby just makes it explicit. > > > Incidentally, from the comp.lang.functional FAQ: > > "Functional programming is a style of programming that emphasizes the > evaluation of expressions, rather than execution of commands. The > expressions in these language are formed by using functions to combine > basic values. A functional language is a language that supports and > encourages programming in a functional style." > > and from NIST: > > "Definition: A language that does not allow any destructive > operation---one which overwrites data---such as the assignment > operation. Purely functional languages are free of side effects, i.e., > invoking a function has no effect other than computing the value > returned by the function." > > --- SER Well, ruby _is_ based on evaluation of expressions. Even control structure expressions have value (though the value of a while always seems to be nil). Also, OOP and FP can coexist. String#gsub, for example, is a pure function that could be implemented differently in different instances of String. Much of the ruby library could (in theory) be implemented in this way. However, Ruby encourages using objects to store state that changes during execution of the program, so I wouldn't argue that ruby was a functional language, just that it has some functional aspects.