Mikael Brockman <phubuh / phubuh.org> wrote in message news:<87llhx2hec.fsf / phubuh.org>...
> Lots of functional languages lack pattern matching.  Scheme, for
> example.  One can write Scheme-styled code in Ruby.

In this, and following posts, you make the claim (directly and
indirectly) that all languages are functional languages, rendering the
term "functional language"  meaningless, or at least useless.  I
oppose attempts to generalize words into meaninglessness.

There *are* good, useful definitions of what constitutes a functional
languages, and Ruby does not match the criteria for most of them. 
Probably the most fundamental of all criteria is that the language
does not allow side-effects, such as assignment.

I'll concede that, if you're allowed to write a lot of non-functional
code in the form of a library, it is possible to write a Ruby
application that is visually indistinguishable from a purely
functional program.  I'll even grant that it is possible to write a
few very short programs using only the inherited functions in Kernel,
ignoring the fact that math in Ruby is, in fact, method calls on
objects rather than function calls or primative operations.  However,
I'll maintain that this is a far cry from satisfying the claim that
one can do functional programming in Ruby.

> I disagree.  Ruby lacks purely functional I/O, but so do Scheme and
> Lisp.  I don't see why Scheme would surpass Ruby's functional
> programming ability.

Because they satisfy several other criteria that are usually
attributed to functional programming languages, such as support for
optimized tail recursion.  They may not be "purely" functional, but
Ruby is about as contaminated a functional language as is possible to
achieve.

And maybe that's a more useful way of looking at this.  I doubt that
there are many languages that are less "functional" than Ruby.

> 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.

No they aren't.  car and cdr aren't methods on objects.  They are
functions that take objects as arguments.

Now, a better example would have been to point out OCaml, which is
*both* functional *and* OO, something which I believe is fundamentally
impossible, in that it can't be pure OO and pure functional.  However,
it has a lot of features associated with functional languages, and
many features associated with OO, so it can claim to be a functional
language with OO capabilities.

--- SER