I remembered another thing about dynamic casting which is not
specifically relevant to the changes in this review, and which should be
pretty well known, but I'll record it here for the sake of completeness.

Wherever there is alternative processing predicated on type, e.g.

    if (A *a = dynamic_cast<A *> (info.grob ())) { ... }
    else if (B *b = dynamic_cast<B *> (info.grob ()) { ... }
    else if (C *c = dynamic_cast<C *> (info.grob ()) { ... }

the reader should stop and consider that perhaps defining a virtual
method would be better.  It could be the case that there is only one
block that does something and the others are omitted.

Again, this pattern is more easily recognized with the casts out in the
open than if they were obscured as, info.item(), info.spanner(), etc.


lilypond-devel mailing list

Reply via email to