On Fri, Dec 14, 2001 at 11:02:51AM +1100, Ben Stanley wrote:

> class InsetA : public Inset {
> // blah blah
>    virtual void Accept(InsetVisitor& iv ) { iv.VisitInsetA(*this); }
> };
> 
> class InsetVisitor {
> // blah blah
>    virtual void VisitInsetA( InsetA& ) = 0;
> };

what's the point in calling back like this ? This looks like it requires
an VisitInsetX for every class X ? And furthermore, one that must be
public.

What is wrong with :

  for (InsetIterator i = insets.begin(); i != insets.end(); ++i) {
                if (i->allowSpellcheck()) {
                        spellcheckInset(*i); // private method of Spell class
                } else if (i->somethingSpecial()) {
                        spellcheckSpecialInset(*i);
                }
  }

exactly ?

this centralises the spellchecking code, and reduces public code.

Note: everyone agrees the current method of not using an iterator isn't good ...

> (I usually define some fancier ways of doing this so that information 
> can be passed to the spell checker object, but this is simplest for 
> illustration.)

which is another disadvantage of your scheme ...

> that you only need to add one method to every inset - the Accept method. 
> From then on, you are free to define new operations upon insets without 
> touching the insets themselves...

I think this is a dubious advantage. Explain to me again why it is better
that the information an inset should not be spellchecked is part of the
Spell class rather than part of the MyInset class ?

regards
john

-- 
"Of all manifestations of power, restraint impresses the most."
        - Thucydides

Reply via email to