Callbacks in C++ Using Template Functors – Rich Hickey (1994)
14 hours ago
- #Callbacks
- #C++
- #Object-Oriented Programming
- Object-Oriented programming promises plug-and-play software design with reusable components.
- Callbacks provide a mechanism for independently developed objects to connect, vital for plug-and-play programming.
- Current callback implementations suffer from lack of generality and type safety.
- A flexible callback technique using template functors is introduced, which behaves like functions.
- Callbacks are used for notification, two-way communication, or distributing work in a process.
- The callback mechanism must be object-oriented, type-safe, non-coupling, non-type-intrusive, generic, and flexible.
- Existing mechanisms like function pointers and single-rooted hierarchies have limitations.
- Template functors offer a solution by allowing type-safe, flexible callbacks without language extensions.
- The implementation involves Functor classes, Translator classes, and makeFunctor functions.
- The callback library is tested with several compilers and is ARM compliant with minor exceptions.