lilypond-devel
[Top][All Lists]
Advanced

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

for_UP_and_DOWN


From: Łukasz Czerwiński
Subject: for_UP_and_DOWN
Date: Sat, 14 Apr 2012 16:10:50 +0200

On 1 April 2012 08:26, Graham Percival <address@hidden> wrote:
On Sun, Apr 01, 2012 at 06:12:27AM +0000, address@hidden wrote:
> On 2012/04/01 05:00:25, Graham Percival wrote:
> >it would be much nicer if there was a macro for this.
>
> It is better to define macros for just the part inside the for(...) .
> Then we can write, and auto-indenters can indent,
>
> for (UP_and_DOWN(d))
>   { ... }
> for (LEFT_and_RIGHT(d))
>   { ... }

ooh, I like that!  I really, really like it!

> However, is a macro nicer ?

Yes, absolutely.

> The first time every new contributor sees this loop form, she has to
> take the time to understand it.  The macro adds two steps to initial
> understanding: realizing that this must be a macro, and then searching
> for the macro definition.

I disagree.  If there's a macro like that, used everywhere in the
code base, then as a new contributor I'd be happy assuming that it
does what it claims.  If UP_and_DOWN(d) was broken, then surely
there'd be tons of breakage all over the code.  I consider this a
useful abstraction.

Now, there should probably be a paragraph explaining those two
macros in the CG.  But that's a minor detail.

- Graham

Hi,

I've uploaded my patch without for_UP_and_DOWN, but now it's time to talk about this #define. I'd like to make a second patch that will introduce that, but there was no consensus.
If you don't know, what I am talking about, take a quick look at: http://codereview.appspot.com/5975054/diff/1/flower/include/direction.hh (lines 75-90).

Opinions:

Keith: LGTM, except that it confuses the two programs we have used recently for

automatic code indentation.

Graham:

I don't find that for loop to be particularly easy to understand; it
would be much nicer if there was a macro for this.

Keith:
It is better to define macros for just the part inside the for(...) .  Then we
can write, and auto-indenters can indent,

for (UP_and_DOWN(d))
  { ... }
for (LEFT_and_RIGHT(d))
  { ... }

What do you think about those macro/function macros?

Łukasz


reply via email to

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