From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19643 invoked by alias); 9 Jan 2019 19:49:28 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 19620 invoked by uid 89); 9 Jan 2019 19:49:27 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.2 spammy=formulations, route, gave X-HELO: simark.ca Received: from simark.ca (HELO simark.ca) (158.69.221.121) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 09 Jan 2019 19:49:26 +0000 Received: by simark.ca (Postfix, from userid 112) id 8A2DB1E7B9; Wed, 9 Jan 2019 14:49:24 -0500 (EST) Received: from simark.ca (localhost [127.0.0.1]) by simark.ca (Postfix) with ESMTP id 8813A1E4C0; Wed, 9 Jan 2019 14:49:23 -0500 (EST) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Wed, 09 Jan 2019 19:49:00 -0000 From: Simon Marchi To: Tom Tromey Cc: gdb-patches@sourceware.org Subject: Re: [PATCH 00/12] Remove some ALL_* iteration macros In-Reply-To: <87h8el1raa.fsf@tromey.com> References: <20181125165439.13773-1-tom@tromey.com> <4406ff6a-975d-0db7-747c-27c7edda8bdb@simark.ca> <87y381v2iu.fsf@tromey.com> <87h8el1raa.fsf@tromey.com> Message-ID: <85c79e69a5c6bbdaca240304c47e7a3f@simark.ca> X-Sender: simark@simark.ca User-Agent: Roundcube Webmail/1.3.6 X-SW-Source: 2019-01/txt/msg00204.txt.bz2 On 2019-01-06 15:10, Tom Tromey wrote: >>>>>> "Simon" == Simon Marchi writes: > > Simon> I think what you did is easy to read, since it's pretty > Simon> straightforward. We could always make an exception for these > Simon> constructs, but it would probably end up being confusing to > understand > Simon> and explain when you can omit the braces and when you can't. > > [...] > > Simon> And let's say that all_compunits (program_space *) returns > tuples of > Simon> , we'll be able to use structured > Simon> bindings when we switch to C++17 :). Something like: > > Simon> for (const auto &[objfile, compunit] : all_compunits (pspace)) > > I gave this a brief try. I wrote a "nested" iterator to make this > generic and then converted all_compunits. > > With the nested iterator, one needs to write: > > for (auto blah : all_compunits ()) > { > compunit_symtab *s = blah.second; > > This looked ugly to me. In that case it would always return a specialized struct struct { objfile *objfile; compunit_symtab *compunit; }; > Alternatively, we'd have to write a "second-selecting" wrapper > iterator. > I didn't implement it but I suppose it would look like: > > for (compunit_symtab *s : second_adapter ()) > ... > > This seemed a bit obscure to me, though. > > In the end I think I prefer the explicit route. It does need more > indentation (I will add the missing braces), but the explicitness seems > good. To me, there doesn't seem to be a strong reason to prefer the > shorter formulations; and the new iterators and adapters that would be > needed are just a bunch more code to try to track through. > > Let me know what you think about this. If you like the second_adapter > approach, I can implement that. Yeah, I think the second_adapter approach just makes things more obscure. Really, I am fine with what you did. Simon