|
|
|
|
|
by chancho
5424 days ago
|
|
> 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. |
|
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.