From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 129682 invoked by alias); 6 Jan 2019 20:10:10 -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 129663 invoked by uid 89); 6 Jan 2019 20:10:09 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=converted, adapters, gave X-HELO: gateway30.websitewelcome.com Received: from gateway30.websitewelcome.com (HELO gateway30.websitewelcome.com) (192.185.145.3) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 06 Jan 2019 20:10:08 +0000 Received: from cm14.websitewelcome.com (cm14.websitewelcome.com [100.42.49.7]) by gateway30.websitewelcome.com (Postfix) with ESMTP id 7EAB346E8 for ; Sun, 6 Jan 2019 14:10:06 -0600 (CST) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id gEkIgxgAb2qH7gEkIgcz3o; Sun, 06 Jan 2019 14:10:06 -0600 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Content-Type:MIME-Version:Message-ID:In-Reply-To:Date: References:Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=wLVYHYh+WFg7uZe9NEs0KI2rkslL7SVP27b9u85agZE=; b=j/UtPmCOBcWqDth+1Emu77WtMw az8tTB8nGHdROwV77GhI9S89Y7IP+VGowO3az9ZiDo2VysXB6qcT2wliChZvqs1ddFVZLHhyzCy3A PoMl0sQlkhVm678pZ0c8iU7z4; Received: from 75-166-72-210.hlrn.qwest.net ([75.166.72.210]:49154 helo=bapiya) by box5379.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.91) (envelope-from ) id 1ggEkI-0019lJ-5Z; Sun, 06 Jan 2019 14:10:06 -0600 From: Tom Tromey To: Simon Marchi Cc: Tom Tromey , gdb-patches@sourceware.org Subject: Re: [PATCH 00/12] Remove some ALL_* iteration macros References: <20181125165439.13773-1-tom@tromey.com> <4406ff6a-975d-0db7-747c-27c7edda8bdb@simark.ca> <87y381v2iu.fsf@tromey.com> Date: Sun, 06 Jan 2019 20:10:00 -0000 In-Reply-To: (Simon Marchi's message of "Thu, 03 Jan 2019 17:45:00 -0500") Message-ID: <87h8el1raa.fsf@tromey.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1.90 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-SW-Source: 2019-01/txt/msg00092.txt.bz2 >>>>> "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. 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. Tom