From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22826 invoked by alias); 10 Apr 2012 17:29:55 -0000 Received: (qmail 22809 invoked by uid 22791); 10 Apr 2012 17:29:53 -0000 X-SWARE-Spam-Status: No, hits=-7.1 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,KHOP_THREADED,RCVD_IN_DNSWL_HI,RCVD_IN_HOSTKARMA_W,SPF_HELO_PASS,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 10 Apr 2012 17:29:36 +0000 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q3AHTVni018358 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 10 Apr 2012 13:29:32 -0400 Received: from [10.36.5.101] (vpn1-5-101.ams2.redhat.com [10.36.5.101]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id q3AHTT9k025978; Tue, 10 Apr 2012 13:29:29 -0400 Subject: Re: Switching to C++ by default in 4.8 From: Torvald Riegel To: Michael Matz Cc: Xinliang David Li , Jakub Jelinek , Richard Guenther , Bernd Schmidt , Gabriel Dos Reis , David Edelsohn , Diego Novillo , gcc In-Reply-To: References: <4F7B356E.9080003@google.com> <4F7C35A3.3080207@codesourcery.com> <20120410084614.GJ6148@sunsite.ms.mff.cuni.cz> Content-Type: text/plain; charset="UTF-8" Date: Tue, 10 Apr 2012 17:29:00 -0000 Message-ID: <1334078968.11195.64.camel@triegel.csb> Mime-Version: 1.0 Content-Transfer-Encoding: 7bit X-IsSubscribed: yes Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org X-SW-Source: 2012-04/txt/msg00358.txt.bz2 On Tue, 2012-04-10 at 18:24 +0200, Michael Matz wrote: > Hi, > > On Tue, 10 Apr 2012, Xinliang David Li wrote: > > > >> > exp->as_component_ref().get_field() .. > > > > Actually it's not questionable. The above stuff is _horrible_. > > > > Specifics please. It is _horrible_ because you are more used to the > > existing way and the new style does not match your taste or they are > > very hard to understand and use? > > Your style (I wouldn't call it The New Style) is visually distracting, and > therefore harder to understand and use, longer to write and full of > syntactic noise without any whitespace. Quite frankly, how anyone could > ever say that > > exp->as_component_ref().get_field() > > is easier to read/write/use than > > GET_FIELD_DECL (exp) > > (say when we #define GET_FIELD_DECL(x) TREE_OPERAND(x,1)), with or without > all-caps, is completely beyond me. I pretty much hope that we never see > the ugliness of the first way in GCCs code base. Even in C++ it's > possible to write non-spaghetti code. I don't see how this is spaghetti code. It it slightly longer, but that's just the case in this specific example. Think about programmers new to GCC for a second, and about code completion tools. It seems to me that with such a tool it's much easier to navigate from exp to the field, than having to scan through a much larger number of accessor functions / macros (GET_*). The former example starts at the source (exp) and yields/"builds" the result; the latter names some function and then says applies it to the source. Why is the former so much worse? To me, the former's structure is easier to see, and if I would have to put the spaghetti tag on something, then the latter. Also, how do you envision code completion to work with the latter? Type exp first, and then have it show which functions take arguments compatible with exp, and then replace it? If a programmer doesn't remember all of the GCC APIs, code completion tools are very convenient. Torvald