This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB 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: [PATCH 00/12] Remove some ALL_* iteration macros


>>>>> "Simon" == Simon Marchi <simark@simark.ca> writes:

Simon> I was wondering if you had thought about replacing, for example
Simon>   ALL_COMPUNITS (objfile, s)
Simon> with an equivalent like this
Simon>   for (compunit_symtab *s : all_compunits (current_program_space))
Simon> in order to avoid nested loops like
[...]

Yeah, I don't think I really considered it.

Simon> I am not sure which one I like best.  The flat version reduces indentation, but
Simon> the nested version makes it clear and explicit how the data is represented, so
Simon> it might help readers who are less familiar with the code.

Same for me.  Maybe I lean a bit toward the explicit form but that might
only be because I already have the patch in hand.

Simon> Also, in theory, according to the coding style, we should write
Simon> for (...)
Simon>   {
Simon>     for (...)
Simon>       {
Simon>         ...
Simon>         ...
Simon>       }
Simon>   }

I thought it was ok to leave a single statement unbraced, though I
personally never do this for something like:

   for (...)
     if ...
     else...

...since I think that's less readable than the braced version.

If the braces are needed then that probably argues for a smarter
iterator, to avoid excessive indentation.

Tom


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