From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27089 invoked by alias); 9 Apr 2012 10:40:37 -0000 Received: (qmail 27079 invoked by uid 22791); 9 Apr 2012 10:40:37 -0000 X-SWARE-Spam-Status: No, hits=-4.8 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,KHOP_RCVD_TRUST,KHOP_THREADED,RCVD_IN_DNSWL_LOW,RCVD_IN_HOSTKARMA_YE X-Spam-Check-By: sourceware.org Received: from mail-iy0-f175.google.com (HELO mail-iy0-f175.google.com) (209.85.210.175) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 09 Apr 2012 10:40:20 +0000 Received: by iaag37 with SMTP id g37so5965621iaa.20 for ; Mon, 09 Apr 2012 03:40:20 -0700 (PDT) MIME-Version: 1.0 Received: by 10.50.183.193 with SMTP id eo1mr4416833igc.20.1333968019950; Mon, 09 Apr 2012 03:40:19 -0700 (PDT) Received: by 10.42.228.200 with HTTP; Mon, 9 Apr 2012 03:40:19 -0700 (PDT) In-Reply-To: References: <4F7B356E.9080003@google.com> <4F7C35A3.3080207@codesourcery.com> Date: Mon, 09 Apr 2012 10:40:00 -0000 Message-ID: Subject: Re: Switching to C++ by default in 4.8 From: Richard Guenther To: Lawrence Crowl Cc: Bernd Schmidt , Gabriel Dos Reis , David Edelsohn , Diego Novillo , gcc Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable 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/msg00271.txt.bz2 On Thu, Apr 5, 2012 at 10:06 PM, Lawrence Crowl wrote: > On 4/5/12, Richard Guenther wrote: >> On Apr 4, 2012 Lawrence Crowl wrote: >> > On 4/4/12, Richard Guenther wrote: >> > > Making tree or gimple a C++ class with inheritance and >> > > whatever is indeed a huge waste of time and existing developer >> > > ressources (that, if only because they have to adapt and >> > > maintain two completely different code-bases over some time). >> > >> > Trees are presently a significant problem in that many static >> > errors become dynamic errors, which entails more debugging. >> >> How do you expect tree errors to become static? =A0By using derived >> types everywhere? =A0Note that this would only be possible in a >> _very_ limited sub-set of places. > > Yes, a class hierarchy that directly represents the type hierarchy > already implicit in trees. =A0With that structure in place, functions > that require a certain kind of tree as a parameter can say so > directly in the parameter list. =A0Functions that return a certain > kind of tree can say so in the return type. =A0Calling a function > that is inappropriate to the type will result in a static error. > > Certainly there are cases where the type must be made more specific, > and getting the wrong type here would necessarily be a dynamic check. > However, the number of dynamic checks can be substantially reduced. > To provide a specific example, suppose I have a common_decl *p and > need to do extra work if it is a var_decl. > > do_general_work (p); > if (var_decl *q =3D p->to_var ()) > { > =A0do_var_work_1 (q); > =A0do_var_work_2 (q); > =A0do_var_work_3 (q); > =A0do_var_work_4 (q); > } > > The only dynamic work is in the pointer conversion. =A0All other > function calls can be statically typed. Ok. But the above represents a completely different programming style than what we use currently. We do if (is_var_decl (p)) { do_var_work_1 (p); ... } so what I was refering to was static errors we get when we are able to promote function argument / return types to more specific sub-classes. >> > > I expect the GCC core to maintain written in C, compiled >> > > by C++. >> > >> > Converting VECs to C++ vectors vector would provide significant >> > code clarity benefits. =A0The files in which that is done would >> > necessarily be C++ only. >> >> I already had VECs as the very first and best example why C++ >> might be good. > > But my point was that if we're using a C++ vector, the files are > not written in C any more. Of course - the whole point was to switch to C++ and start using C++ features. The point I wanted to raise is that the switch to C++ should happen with a change that is useful and that includes getting GC "right". Converting vec.h is such a change. Richard. >> > > > I also find debugging C++ in gdb somewhat more annoying >> > > > than debugging plain C, and at the moment I always go back >> > > > to a stage1 compiler. >> > > >> > > Indeed - I'd be worried if my debugging efficiency decreases >> > > by more than 5%. >> > >> > If the number of debugging sessions was reduced by the same >> > amount, the result would be a net wash. >> >> I have no expectation that the number of debug sessions will >> be reduced. > > On the other hand, I do. =A0There are many instances were I've debugged > a problem to realize that it could have been a static type error. > > -- > Lawrence Crowl