Signals + slots *can* be done without using stupid preprocessors. I very much doubt Bjarne would have anything much against a decent, well designed implementation of them. Which Qt's moc isn't, of course.
However, the gtk++ spinoff libsigc++ does them very well - I'd love to see a Qt port that used libsigc++ instead of that braindead (actually rather clever, but fundamentally flawed) moc preprocessor. Thing is, at the time Qt was written, most C++ implementations lacked many of the features around today, and so moc was a workaround, and like most kludges, now they are stuck with it unless they want to axe backward compatibility. (Maybe Qt 3.0 would be a good time to actually do this.)
If you haven't seen libsigc++, here's a summary :
This library implements a full callback system for use in widget libraries, abstract interfaces, and general programming. Originally part of the Gtk--
widget set, libsigc++ is now a seperate library to provide for more general use. It is the most complete library of its kind with the ablity to connect an
abstract callback to a class method, function, or function object. It contains adaptor classes for connection of dissimilar callbacks and has an ease of
use unmatched by other C++ callback libraries. Libsigc++ is licensed under the GNU Library General Public License, LGPL.
- Compile time typesafe callbacks (faster than run time checks)
- Typesaftey violations reports line number correctly with template names (no tracing template failures into headers)
- No compiler extensions or meta compilers required
- Proper handling of dynamic objects and signals (deleted objects will not cause seg faults)
- Extendable API at any level Slot, Connection, Object, and Signal
- Extensions do not require alteration of basic components to allow use of extensions
- User definable marshallers
- Provides headers for up to 7 arguments and 2 callback data
- M4 Macros for building templates with various numbers of arguments and callback data
- Easily build support for templates with number of arguments and callback data not defined in library headers
- Now supports gcc 2.8.0, egcs all versions, gcc 2.95.x, HP aCC A.01.22, Irix MipsPro 7.3, RISC OS with gcc 2.95, and Visual C++ 5.0.
The original library was composed by Tero Pulkkinen for the Gtk-- system, a C++ wrapper for the Gtk+ widget set. The revised library is written and mantained by Karl
Nelson. Special thanks for Esa Pulkkinen for development tips.
[ Parent ]