
"functors" in c++, ML, haskell, prolog - gtani
http://www.catonmat.net/blog/on-functors/
======
freedrull
This is an old article, but I love this blog. Peteris is so prolific you can't
help but get inspired.

------
chancho
> Take C++ for example. Everyone who has mastered C++ knows that you call a
> class that implements operator() a functor.

Nope. This is what dilettantes call them. Capable C++ programmers (I don't
claim to be a master, that would be foolish) know how to grep the standard.
The term "functor" is not found in it, at least not that draft that comes up
first on Google. The plain and transparent term "function object" has its own
section, 20.3.

~~~
Figs
The term "functor" is widely used -- including such places as SGI's STL
documentation (<http://www.sgi.com/tech/stl/functors.html>) and numerous other
reference sites.

According to Bruce Eckel's _Thinking in C++ Vol 2_ (in the section describing
the Command Pattern), the term dates to 1992:

> In Advanced C++: Programming Styles And Idioms (Addison Wesley, 1992), Jim
> Coplien coins the term functor which is an object whose sole purpose is to
> encapsulate a function (since “functor” has a meaning in mathematics, we
> shall use the more explicit term function object). The point is to decouple
> the choice of function to be called from the site where that function is
> called.

Unfortunately, I don't have a copy of Advanced C++: Programming Styles and
Idioms, so I can't verify this myself. But, if it's accurate, that means the
term predates the standard by at least six years since ISO/IEC 14882 was
released in 1998... :)

Personally, I do prefer "function object" though, since it seems like a
clearer term.

~~~
chc
Bjarne Stroustrup's own "The C++ Programming Language" introduces them that
way on page 515 as "a function-like object, a functor, or simply a function
object". I don't like the term either, but that seems like a pretty
authoritative source giving its blessing.

