News for hackers. Stuff that matters.
Re:Rich Hickey on Functors in C++ (1994) by tptacek on Tuesday July 17, 2012 @12:48PM (#4256555)
I know everyone here knows Rich Hickey from Clojure, but I'm a C/C++ programmer from the '90s and I primarily know him for "Hickey functors", which were the de facto standard way of doing object-oriented callbacks in C++.

Also, while I am sure they were for the time a near-optimal solution, they are f'ing gross, so "Hickey functor" is a bit of an epithet. "Oh well, better than Hickey functors" was a justification for a lot of Gang-of-four pattern goop in my C++ code.

Re:Rich Hickey on Functors in C++ (1994) by ScottBurson on Tuesday July 17, 2012 @02:43PM (#4257172)
The right thing is what is here being called a "bound pointer". It is actually the correct implementation of a closure: a code pointer paired with a data pointer, where only the code in question needs to know the type of the data pointer.

I proposed it to Stroustrup et al. in 1992, but was ignored.

I don't recall their rationale for rejecting it, but I think time has borne me out.

Re:Rich Hickey on Functors in C++ (1994) by scott_s on Tuesday July 17, 2012 @03:42PM (#4257474)
I know from D&E that the C++ committee has a policy of only accepting new features which had an existing implementation and first-hand accounts of using the feature.
Re:Rich Hickey on Functors in C++ (1994) by mkup on Tuesday July 17, 2012 @05:39PM (#4258074)
There was existing implementation in 90s, bound pointers were implemented in Borland C++ Builder (__closure keyword).
Re:Rich Hickey on Functors in C++ (1994) by scott_s on Tuesday July 17, 2012 @11:42PM (#4259244)
Then I think it's fair to assume the above poster was not the only person to propose it.
Re:Rich Hickey on Functors in C++ (1994) by ScottBurson on Wednesday July 18, 2012 @01:27AM (#4259494)
I probably wasn't the only one proposing it, but I have no way to know who else might have done so.
Re:Rich Hickey on Functors in C++ (1994) by xefer on Tuesday July 17, 2012 @01:44PM (#4256813)
Even Hickey states in this article that the term comes from James Coplien. His C++ book from 1992 was what first introduced me to the concept.
Re:Rich Hickey on Functors in C++ (1994) by tptacek on Tuesday July 17, 2012 @01:45PM (#4256821)
I know this is true, but "Hickey functors" is what the people who introduced them to me called them.
Re:Rich Hickey on Functors in C++ (1994) by beatbrokedown on Tuesday July 17, 2012 @07:35PM (#4258508)
Just in case anyone forgets this is from 1994(it's in the title!). Typical modern C++ has been using this pattern for quite a while (boost::function / boost::bind) and it is now even part of the standard (std::function / std::bind). So don't go implementing Functor0->Functor9 yourself!

It is always nice though to see how C++ has grown after so many years and clearly still has staying power for even new projects.

Re:Rich Hickey on Functors in C++ (1994) by thought_alarm on Tuesday July 17, 2012 @02:18PM (#4257013)
Back in the 90s Borland extended their C++ compiler to support what he refers to as "bound pointers", which was used with their mostly excellent Windows SDK for C++ and Delphi.

    myButton->onClick = controller->showAboutBox;
Re:Rich Hickey on Functors in C++ (1994) by eliasmacpherson on Tuesday July 17, 2012 @02:19PM (#4257017)
Is this in response the recent article with C++0x, Stepanov and Functors with a nod to Haskell?
Re:Rich Hickey on Functors in C++ (1994) by spacemanaki on Tuesday July 17, 2012 @05:16PM (#4257931)
I'm kinda out of my depth here, as I know next to nothing about C++, but I'm pretty sure it's not. These functors are fundamentally different thing (first-class function object?) from what that other article and what Haskell calls functors (container that can be mapped over).
Re:Rich Hickey on Functors in C++ (1994) by jamesaguilar on Tuesday July 17, 2012 @02:01PM (#4256906)
This is what I normally use. It's not as good as a language that has truly decent support for callbacks, but it's a darn sight better than vanilla C++.
Re:Rich Hickey on Functors in C++ (1994) by shizzy0 on Tuesday July 17, 2012 @06:44PM (#4258319)
No wonder Hickey ditched C++.