This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH 00/12] Remove some ALL_* iteration macros
- From: Tom Tromey <tom at tromey dot com>
- To: Simon Marchi <simark at simark dot ca>
- Cc: Tom Tromey <tom at tromey dot com>, gdb-patches at sourceware dot org
- Date: Thu, 03 Jan 2019 14:45:29 -0700
- Subject: Re: [PATCH 00/12] Remove some ALL_* iteration macros
- References: <20181125165439.13773-1-tom@tromey.com> <4406ff6a-975d-0db7-747c-27c7edda8bdb@simark.ca>
>>>>> "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