This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [gcc-in-cxx] Revert adding newlines for semicolon in loops


On Mon, May 25, 2009 at 4:36 AM, Eric Botcazou <ebotcazou@adacore.com> 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
notwithstanding =)

> n = 0;
> for (e = rdg->vertices[i].succ; e; e = e->succ_next)
> ?n++;
>
> is probably clearer indeed, albeit less elegant.
>
> --
> Eric Botcazou
>


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]