Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fq1K1-0000yy-31 for pgsql-hackers@arkaria.postgresql.org; Wed, 15 Aug 2018 19:19:09 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fq1Jy-0000ZU-KE for pgsql-hackers@arkaria.postgresql.org; Wed, 15 Aug 2018 19:19:06 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fq1Jy-0000ZN-9g for pgsql-hackers@lists.postgresql.org; Wed, 15 Aug 2018 19:19:06 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fq1Ju-0000SU-Ng for pgsql-hackers@lists.postgresql.org; Wed, 15 Aug 2018 19:19:05 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id w7FJIvMf020826; Wed, 15 Aug 2018 15:18:57 -0400 From: Tom Lane To: Andrew Dunstan cc: Robert Haas , Andres Freund , PostgreSQL Hackers Subject: Re: C99 compliance for src/port/snprintf.c In-reply-to: References: <17245.1534289329@sss.pgh.pa.us> <9456.1534347706@sss.pgh.pa.us> <20180815155237.pz5fgfmdo4cgqjta@alap3.anarazel.de> <11138.1534349838@sss.pgh.pa.us> Comments: In-reply-to Andrew Dunstan message dated "Wed, 15 Aug 2018 14:59:46 -0400" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <20824.1534360737.1@sss.pgh.pa.us> Date: Wed, 15 Aug 2018 15:18:57 -0400 Message-ID: <20825.1534360737@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Andrew Dunstan writes: > On 08/15/2018 12:17 PM, Tom Lane wrote: >> Robert Haas writes: >>> Personally, I'd prefer to >>> continue avoiding // comments and intermingled declarations of >>> variables and code on grounds of style and readability. >> ... which I agree with. > A decade or so ago I would have strongly agreed with you. But the > language trend seems to be in the other direction. And there is > something to be said for declaration near use without having to use an > inner block. I'm not advocating that we change policy, however. FWIW, the issue I've got with what C99 did is that you can narrow the *start* of the scope of a local variable easily, but not the *end* of its scope, which seems to me to be solving at most half of the problem. To solve the whole problem, you end up needing a nested block anyway. I do dearly miss the ability to easily limit the scope of a loop's control variable to just the loop, eg for (int i = 0; ...) { ... } But AFAIK that's C++ not C99. regards, tom lane