The Name Game
We are in the midst of trying to sell one house (by owner) so we can buy another, due to my accepting a teaching position at a college seventy miles away from where we currently live. Things arent going well. We have yet to have a single person come to see our home. This sorry situation has prompted some to ask if we are going to enlist the services of a realator. I know they meant to say realtor, so I silently cringe and let it pass. Perhaps youve had a similar experience talking to people who have friends majoring in nuculer physics. Mispronunciations are annoying but harmless as long as the intended communication occurs.
You may think the same is true with the terminology we use, but Im not so sure. Technical topics require precise treatment, and sometimes our sloppy conversation promotes confusion, especially when we borrow terms from other disciplines. Im not so much concerned about the term vector, which means something a little different to a programmer than it does to a physicist or mathematician the meanings are actually quite close (although to a microbiologist it means a mechanism by which a disease is spread!). The terms on my chopping block today are functor and functional. What do they mean to you? These terms, like so many others in computer science, are borrowed from the wonderful world of mathematics. I wonder how many of us appreciate the fact that language theory, models of computation, and even type systems existed in the minds of mathematicians long before engineers first put current through silicon. For the life of me, I cant see why we misuse these terms that were well defined long before AT&T and IBM even existed. Heres the low-down, to which any mathematician would attest:
- A function is a transformation that maps an element to an element.
- A functional is a transformation that maps a function to an element.
- A functor is a transformation that maps a function to a function. (The truth functions in propositional logic are also sometimes called functors.)
Simple, isnt it? We seem to use the first one correctly, but not the other two. What people commonly call a functor (thanks to Dr. Coplien, shame!) is what the C++ Standard calls a function object. It seems some people like to use functional to mean the same thing. Shame again! A function object is simply that, an instance of a class that behaves like a function by virtue of its operator(). Some function objects, like bind2nd, do behave like functors, in that they take a function object as input and return a function object as output. Only these deserve the functor moniker, although you may prefer function object adaptor (or is it spelled adapter :-), as denoted in the C++ Standard.
As I stated earlier, communication is the goal, so if everyone understands these terms equivalently, then no harm done. But do they? I dont think so.
Stop making me cringe!
Chuck Allison
Senior Editor