On Wed, Oct 23, 2002 at 05:29:40PM +0100, John Levon wrote: > > I don't see much that's worth the extra complexity, _especially_ if you > > want to access that with base class pointers/references as this basically > > ends up implementing something like vtables. The compiler is better at > > that. > > So how /would/ this work with base class pointers ?
Basically using some wrapper template like template <class Func> void do_it(Func what, base * p) { if (dynamic_cast<derived1 *>(p)) what(dynamic_cast<derived1 *>(p) else if (dynamic_cast<derived2 *>(p)) what(dynamic_cast<derived2 *>(p) ... } and call everything that need run-time virtual dispatch (i.e. almost evertyhing in the insets) via do_it with some suitable function object. One can play a few tricks here that I can't remember anymore to make this less ugly... Anyway: in simple words: It would not work at all. > I find the current scheme not scalable It scales to the size we need. What exactly is not scalable? > and very ugly. I know no better solution. > Not to mention the recompile of everything when you add a new one. I am certainly missing the point. If I add an inset I have to recompile the parser, the factory, and the inset itself. What else is needed? > I am trying to reduce the horrendous size of the Inset/UpdatableInset > classes. No problem with that. As I said: 40 functions should do. > They are too large to work with. I like the idea of centralising the > traits, it is far easier to understand. What is the conceptual difference between traits and virtual functions except that the former work on static types at compile time and the latter on dynamic types at run types? Or are we talking about visitors once more? > > Moreover, not many people will understand that "pattern" whereas even > > the average Java programmer has a good grasp of virtual functions (even > > if "virtual" sounds unfamiliar). So from a purely practical POV: Why > > bother? > > I don't buy this argument. I don't see you technical point. Andre' -- Those who desire to give up Freedom in order to gain Security, will not have, nor do they deserve, either one. (T. Jefferson)