Simen Edvardsen wrote: > > In mathematics and computer science, higher-order functions or > functionals are functions which do at least one of the following: > > * take one or more functions as an input > * output a function > > According to this definition, Ruby's standard library is filled with > higher order functions, as are the libraries of Ocaml, Scheme etc. This comment is extremely interesting. It is actually *not* the case that Ruby's "functions" are functions in the mathematical sense. They are actually objects that point to blocks of executable code or to closures. They have the ability to execute instructions that modify the contents of memory or produce other side effects so as to make visible the results of operations that simulate mathematical functions. But true functional languages directly expose composable mathematical functions (mappings from a possibly infinite domains to ranges). Pure functional languages don't expose any side effects at all. They are extremely effective at modeling computations (I once wrote a complete, correct qsort in 7 lines of ML) but not very good at executing communications or data transport tasks, which are all about side effects. I've often been mystified when people talk about Ruby's metaprogramming, closures, lambdas, etc. as constituting a "functional" programming style. Your comment is striking because it made me realize that perhaps many people who learn languages like Scheme are actually trying to apply the imperative, Turing-style computational model to languages that don't support them. And that reinforces all the more my intuition that pure FP is not well-suited for mainstream professional programming. Years ago, I spent a lot of time trying to teach professional programmers to grasp the functional style. And most people couldn't even let go of the concept of variables as little boxes holding readable and writable values. That's when I gave up on FP. -- Posted via http://www.ruby-forum.com/.