lilypond-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Issue 5336: Remove downcasting methods from Grob_array and Grob_info


From: nine . fierce . ballads
Subject: Re: Issue 5336: Remove downcasting methods from Grob_array and Grob_info (issue 344010043 by address@hidden)
Date: Tue, 12 Jun 2018 14:37:55 -0700

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.

https://codereview.appspot.com/344010043/



reply via email to

[Prev in Thread] Current Thread [Next in Thread]