lilypond-devel
[Top][All Lists]
Advanced

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

Re: for_UP_and_DOWN


From: Łukasz Czerwiński
Subject: Re: for_UP_and_DOWN
Date: Sun, 15 Apr 2012 16:13:13 +0200



On 14 April 2012 18:06, David Kastrup <address@hidden> wrote:

Is this supposed to declare d itself or not?

Yes, it will declare d as a variable visible only in for loop (I'm using a new way of handling variables declared in for() clause - those variables will no longer be visible outside the for() loop).

On 14 April 2012 18:32, Graham Percival <address@hidden> wrote:
On Sat, Apr 14, 2012 at 06:06:41PM +0200, David Kastrup wrote:
> Graham Percival <address@hidden> writes:
>
> >> > for (UP_and_DOWN(d))
> >> >   { ... }
> >> > for (LEFT_and_RIGHT(d))
> >> >   { ... }
> >>
> > Not yet.  I just wanted to clarify what you were talking about,
> > since most people don't have the time to go trawling through
> > rietveld discussions.  If something is difficult to understand,
> > the first instinct is just to ignore the discussion.
>
> Is this supposed to declare d itself or not?

... probably?


Lukasz, could we have a nice concise example of exactly what the
final suggestion is?  What's the macro?

- Graham

The final suggestion depends on suggestions from all of you. If you find a better idea for (UP_and_DOWN(d)), I'll do so. If you find easier: for_UP_and_DOWN, it could be this. 

I'd like to write code, that will make Lilypond better or easier to be used and it's not my goal to fulfill my ambitions to force unwanted changes, so:

1) As Graham and Keith wanted for(UP_and_DOWN), the macro and example is:

#define UP_and_DOWN(d) \
Direction d = UP; d != CENTER; flip(&d), d == UP ? d = CENTER : d

int main() {
for(UP_and_DOWN(d)) {
printf("%d\n", (int)d);
}
}

The example will print the integer value for UP and then the integer value for DOWN:
-1 


2) If the macro would be for_UP_and_DOWN, those would be:


#define for_UP_and_DOWN(d) \
for(Direction d = UP; d != CENTER; flip(&d), d == UP ? d = CENTER : d)

int main() {
for_UP_and_DOWN(d) {
printf("%d\n", (int)d);
}
}

The output is of course the same - the integer value for UP and then the integer value for DOWN:
-1 

Which option should I include in the Lilypond's code? As I wrote earlier, there were 2 votes for 1)

Łukasz


reply via email to

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