This is the mail archive of the
mailing list for the GCC project.
Re: [gcc-in-cxx] Revert adding newlines for semicolon in loops
On Mon, May 25, 2009 at 4:36 AM, Eric Botcazou <firstname.lastname@example.org> wrote:
>> Why not just do:
>> for (n = 0, e = rdg->vertices[i].succ; e; n++)
>> ? e = e->succ_next;
>> With all the talk about readability, it seems people are overlooking
>> how much you have to disect the for statement to find out what the
>> loop does. ?The actual action should be placed in the body of the loop
>> for readabilitiy, not cramed into the for statement. ?The talk about a
>> semicolon seems, to me, to pale in comparison for "readability" sake.
> e = e->succ_next is not the actual action, it's the iteration so it should
> stay in the 'for'. ?Counting loops like this are usually written with an
> empty body, although
There you go. So as written originally, it's not as clear as it could
be, since I easily got it wrong (jabs at my ability to get it right
> n = 0;
> for (e = rdg->vertices[i].succ; e; e = e->succ_next)
> is probably clearer indeed, albeit less elegant.
> Eric Botcazou