From owner-freebsd-current@FreeBSD.ORG Sun Feb 15 18:50:06 2009 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 516181065678 for ; Sun, 15 Feb 2009 18:50:06 +0000 (UTC) (envelope-from xcllnt@mac.com) Received: from asmtpout020.mac.com (asmtpout020.mac.com [17.148.16.95]) by mx1.freebsd.org (Postfix) with ESMTP id 390B68FC1C for ; Sun, 15 Feb 2009 18:50:06 +0000 (UTC) (envelope-from xcllnt@mac.com) MIME-version: 1.0 Content-transfer-encoding: 7BIT Content-type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Received: from mbanic-mbp.jnpr.net (natint3.juniper.net [66.129.224.36]) by asmtp020.mac.com (Sun Java(tm) System Messaging Server 6.3-7.03 (built Aug 7 2008; 32bit)) with ESMTPSA id <0KF4004KJC7GT040@asmtp020.mac.com> for freebsd-current@freebsd.org; Sun, 15 Feb 2009 09:50:05 -0800 (PST) Message-id: <8EF8771C-76D8-4556-96B2-B97B35573CBD@mac.com> From: Marcel Moolenaar To: Christoph Mallon In-reply-to: <499835BE.3000705@gmx.de> Date: Sun, 15 Feb 2009 09:50:04 -0800 References: <4995BB1B.7060201@icyb.net.ua> <20090213231513.GA20223@duncan.reilly.home> <4997F105.5020409@icyb.net.ua> <499811DF.6030905@incunabulum.net> <20090215151318.0d17bfb9@ernst.jennejohn.org> <499835BE.3000705@gmx.de> X-Mailer: Apple Mail (2.930.3) Cc: Andrew Reilly , Bruce Simpson , freebsd-current@freebsd.org, Andriy Gapon Subject: Re: weeding out c++ keywords from sys/sys X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 15 Feb 2009 18:50:06 -0000 On Feb 15, 2009, at 7:33 AM, Christoph Mallon wrote: > More robust error handling and less tedious resouce management > directly come to mind: > Just look at normal C functions which allocate resources and have > multiple points which can fail. They are the usual mess of if()s, > goto error and lots of cleanup code. Further all this code looks > pretty much the same in several modules. In C++ you write the > resource handling code once (constructors/destructors) and then you > cannot forget to clean up, because thanks to scoping and defined > life ranges it happens automatically. While on the surface this looks better, under the hood it's just the same. Worse in most likelihood, because with C the programmer writes the logic that is known to be needed (assuming no bugs). With C++ it's the compiler that generates code that handles all possible scenarios, and goes beyond what is strictly needed -- as such the cost tends to be higher, even when there are no errors or exceptions. I'm not saying this is a problem. All I'm saying is that you move responsibility from the programmer to the compiler and in general this comes at a (runtime_ cost. One we may very well accept, mind you... -- Marcel Moolenaar xcllnt@mac.com