From owner-freebsd-questions@FreeBSD.ORG Wed Apr 1 12:11:02 2009 Return-Path: Delivered-To: freebsd-questions@FreeBSD.ORG Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A5DF01065694 for ; Wed, 1 Apr 2009 12:11:02 +0000 (UTC) (envelope-from will.rutherdale@utoronto.ca) Received: from mail.vex.net (smaug.vex.net [208.76.104.132]) by mx1.freebsd.org (Postfix) with ESMTP id 7E17D8FC1E for ; Wed, 1 Apr 2009 12:11:02 +0000 (UTC) (envelope-from will.rutherdale@utoronto.ca) Received: from [192.168.110.8] (unknown [207.35.13.223]) by mail.vex.net (Postfix) with ESMTPA id CEF2317126 for ; Wed, 1 Apr 2009 08:11:00 -0400 (EDT) Message-ID: <49D359D4.60103@utoronto.ca> Date: Wed, 01 Apr 2009 08:11:00 -0400 From: William Gordon Rutherdale User-Agent: Thunderbird 1.5.0.14ubu (X11/20080505) MIME-Version: 1.0 To: freebsd-questions@FreeBSD.ORG References: <200904010839.n318dkuJ050633@lurza.secnetix.de> In-Reply-To: <200904010839.n318dkuJ050633@lurza.secnetix.de> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: Subject: Re: Why?? (prog question) X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 01 Apr 2009 12:11:07 -0000 Oliver Fromme wrote > Of course this is purely a matter of taste and personal > preference. My preference is similar to yours, but my > main reasoon is to save space. I think it is a ridiculous > waste of space if every third line consisted only of a > sole brace (opening or closing). To my eye, such lines > that are almost empty break the natural structure of a > piece of source code. I insert empty lines quite often > in order to group source lines logically, but brace lines > break that grouping visually. > > There is a very logical reason in C for wanting to put the opening brace of an 'if' statement on a separate line: preprocessor statements. Many editors, including vi / vim, and no doubt emacs, have a brace matching facility. If I put the cursor over a closing brace, say, and hit the % key, it puts me onto the matching opening brace. However in this scenario: int foo( int x ) { #ifdef SCENARIO_A if ( x<3 ) { #else if ( x<2 ) { #endif // . . . } // . . . } matching the closing brace of foo() will fail, as the number of braces no longer matches. Putting the opening brace of the 'if' on another line solves this problem. -Will