Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vQoth-0011P0-1O for pgsql-hackers@arkaria.postgresql.org; Wed, 03 Dec 2025 15:36:06 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vQotg-00EBIw-1X for pgsql-hackers@arkaria.postgresql.org; Wed, 03 Dec 2025 15:36:04 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vQotf-00EBIn-32 for pgsql-hackers@lists.postgresql.org; Wed, 03 Dec 2025 15:36:04 +0000 Received: from mail-qk1-x736.google.com ([2607:f8b0:4864:20::736]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1vQotY-002wpF-2E for pgsql-hackers@lists.postgresql.org; Wed, 03 Dec 2025 15:36:03 +0000 Received: by mail-qk1-x736.google.com with SMTP id af79cd13be357-8b602811a01so37148785a.2 for ; Wed, 03 Dec 2025 07:35:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dunslane-net.20230601.gappssmtp.com; s=20230601; t=1764776156; x=1765380956; darn=lists.postgresql.org; h=in-reply-to:autocrypt:content-language:from:references:cc:to :subject:user-agent:mime-version:date:message-id:from:to:cc:subject :date:message-id:reply-to; bh=xpqa8owAhcOxx5QeYCrnV3HHeYJjUhPSJFL6zvGKF0E=; b=RFPL88jg9z3OHrIHL1jxTm2IHxQVH0bfpsrygLtfgcy6FMn4x6pM4Qk608M8N6CTwV lQRh+puTW2UE5uxCz0EbjGR8ndXozsY0gJO87Dxd5Qzzl5hBPhD5qDcbBVS1iB/Q34ge IYpyakJdWuJFo3OOaOXXJAxLp9DAVJv4Fyxcj4fww21IKsaiPbJMAnKWRP0XNyajQvIx lMhQPmKGVO8zqECLoBqHczn8rw6SMygsHr/YMpiod7bolbdgqpqFFG3wOiZz1pIvEjuf TE+SX5uURUpki2eS/mFIwtjK45bMkkigdc8Y/7Qa2pgTAznIOZqKTKz3biCCfx00yiEn JMfQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764776156; x=1765380956; h=in-reply-to:autocrypt:content-language:from:references:cc:to :subject:user-agent:mime-version:date:message-id:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=xpqa8owAhcOxx5QeYCrnV3HHeYJjUhPSJFL6zvGKF0E=; b=gnWWOeonYhGS4fMthkeD7U4ZqnP1cNiRfT9nFAF5YI0KX2OqnCFkLWm491/a7mA8w/ tYFd/XdF1bbY897MS4pa/ZQetV3phERh2r1TrfWeEzgyDy4pRJr0mQVtrAlCzEoVNIq8 hHWC1RhNduEMtmm/+KncgXmEBoybxjAK2Bmy2tYGsjNeCTGAS9qBrdcu9zgj9/HurE+j tUMagNqv2q0utuYRSZQduvLoRyYDXSyo4EMIFFoF5Sr0T3bxFNHz/ujGmIbpnd9aCVVB 5dp0MLweRR5sRAkQmfqs+QaNzdWvUhOea0ITrPZo/ObDSE7FwW9ohYkAEqpdFvIG2S6r tP9w== X-Forwarded-Encrypted: i=1; AJvYcCVAoi25cLzcHGdzOHZTogMM98ikJLqxvS7uOatTI7dPT3CRq0ig6kdNKIVG3S2iDCDy5cZHiNkiiasnX2zV@lists.postgresql.org X-Gm-Message-State: AOJu0YxdW3unRJB76OtSuv20NDc8Ya8XM700HXbeEpt3ctNjqiSRcEXd mAm1q/3otWIr1+AYF8OIx+U8oGKEZ8AU9gFUDFGi9XQtxugFvSxKyJpUmkgNxiF49hk= X-Gm-Gg: ASbGncsVmn7ZaY8ToNyTB8K8hCZAeMILj331UNreayQ9EwSMmkbW5JgQ8yf11CrYeTF ZssWVEEMv4NRa5dDeUnSCnwEdvbJoyLqYXAdF7x+kTcpX0+f2REqvElhs1n47t5L5pKAR6zHiVL H09n9t7XJgg6K90rzjbELLrWtqm8MYs2pEjnb+NdDonxxmm+rtC+9GR5rOIFpmQ5E1W0jKYI8ZB Vk2h0Y76aCrrOiYHHybpetQC+XIo383v5K8Yn35kFF7tFhx8xjK2E3d4+8bVy4pWqq2rbKUH2Lo FVgZyYyKYqQImxgCETCISDFNiUDsxioStD46qxWPETOPu0h7++QLLeFOdT9zTF9Ki+AvYr+H202 lqlQE9CVlwRDwvpNPxDNMIRRtCWvgGuxVwD6Tjf/XdCCeY8zw4/NK+L0zIK0/iGQWCKlnu5FOkr 8pU+ZyKETXghW6RiB5sG7N2AeodCyX X-Google-Smtp-Source: AGHT+IH/kvwHh5ZBdiEu7rtZkCx8DrLKuwQDCw4W61HAg427hmKIK16j2g6F6QtFfEboUHE0FPAknw== X-Received: by 2002:a05:620a:44d5:b0:8b2:d26f:14b0 with SMTP id af79cd13be357-8b5e47a7687mr369079885a.3.1764776155535; Wed, 03 Dec 2025 07:35:55 -0800 (PST) Received: from ?IPV6:2605:a601:a6b0:500::1cb? ([2605:a601:a6b0:500::1cb]) by smtp.googlemail.com with ESMTPSA id af79cd13be357-8b5299a5d48sm1314024985a.12.2025.12.03.07.35.54 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 03 Dec 2025 07:35:55 -0800 (PST) Content-Type: multipart/alternative; boundary="------------e8fAb8MQz13waLCeEt0aF1yY" Message-ID: Date: Wed, 3 Dec 2025 10:35:53 -0500 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: pgindent versus struct members and typedefs To: Chao Li , Tom Lane Cc: Nathan Bossart , Rahila Syed , Robert Haas , PostgreSQL Hackers References: <347EA055-D626-414C-B10D-7E70041B9B55@gmail.com> <509793.1764715875@sss.pgh.pa.us> <5E70CB69-1E2D-471B-8CF8-83205E5E14CE@gmail.com> <512380.1764717196@sss.pgh.pa.us> From: Andrew Dunstan Content-Language: en-US Autocrypt: addr=andrew@dunslane.net; keydata= xsBNBE7KWFkBCAClridxur2AIc7eW2AR7izbfp3EnNefie2HbLF0izW5Ik5UjX2HBXBx4syI gY6b0ugohXrr274+baoAlvSbq6cAoQuEVrk5IZFzt20b1Xkx65FwGSEj526yiKLocqkJceSq Xr9xcA5SGY+FZv441chh5SU92v4q6z+6LPpoHOh97ptAVXZYNTtU0LevyvD5lja0TzbvJm6C eFXitJfnm1pLEr0DGJCR/iUOl/N62Kh4855zZC7NHIjQHPOvV5Stz/l5ilDhvGVk+xkXFPys SjZoUr1rXhYLpiyi5sR0X9FHXT0KnGuz1F5ERO7ZTLSSQ6fJwPj6gOk9K+vvoKvoeql5ABEB AAHNJEFuZHJldyBEdW5zdGFuIDxhbmRyZXdAZHVuc2xhbmUubmV0PsLAlwQTAQgAQQIbAwIX gAIZAQULCQgHAwUVCgkICwUWAgMBAAIeBRYhBOQ+WEYd/Hy/RGkVpZn6f8tZ/DuBBQJoGNGd BQkdEO8nAAoJEJn6f8tZ/DuBq74H/jkTR4Zi3stbw+xC7v2u3QozssK7MYPL2AsVfh7OealS h182fiWXpfvmmAB7WUHbhk9GC2RAOnHI/2d2jgKaMLAHsGYOT0YopTVIwRY43fCw/mK67yxc wmDcX+zyKfLaivNbf5A7QPLNwda98bEAMSJ8Sn652Uc6cA8t3uKGsVzbRBQOoYzjgvBCfSrE 9ql3PDNg0l4BfAqabd2f70ZUm9VAMEPrgv/v2xI7M2XiL4g5BVmqLCOwxLM8RMCotCuoweUr VO43DeBCIDwLxotMJKvGWDjBzQYlU1NPUAtNcz/gN9ITUe1VUGjyvGj4u1lxBOcQQUw7l1+T 5moZ4iZxXzvOwE0ETspYWQEIANGc4zQULOxhbqO2dyD51YhqCNRmm9oKWaqf+wmW4tpDe/VV cxAnNizd4LWCHfzpb5cHAtGkOPePMfzWVf6nvdF7d3eglbtf59+zG7O7llV0xSSoFiieQBsr GvqDInXYX/4mRRXMtyhM353/tixC9RWLs1oofyYmCPPXXY7h9R7en3B8BoVrRFcdzlIY/NFN hFGW/9dkEiGjgna2Rk6e15kln4ZvFBWUg23p93w/pqXcxY6+k/8TEk+C4R+M6w7o2PLGOjdZ +kPiUcw5H85zf/yZJwQXzisXaNduwWB6Vads9YC9dj6kPR1c4VGRqAaYL++LAEOqrlvm2Tvq QqZRtnEAEQEAAcLAfAQYAQgAJgIbDBYhBOQ+WEYd/Hy/RGkVpZn6f8tZ/DuBBQJoGNI2BQkd EODdAAoJEJn6f8tZ/DuBfw0IAKTsfD40teP/pp+bsLLMSxPXUYrrprTj7WFB5v61p6dkpSr/ qXmMlyahdxQFaPmfVgVirB1Vk/kHiWNnnGjfUV9nB2Zg9LI0Xb9/ts3LsUiRWXzG3tkMY6XL vsVOxW4XFRND9l2q+WW93aZ1DZl+fqWfYgMvsusFRhmGFOKTRfKPta2Pkv+AhA24N4+PrR5p bU4k2MO8PAGiK8eaYKGFG1bHKuAvoDoF7WXJ3FHxuWqLnKEt4dfOLm5pAe3zq1Lt6q8azT9i QWGpSAK5vQUWQHBHpiDjdPeqKZ6HiAXIIKfSmb+jrvXBqoP+D6/K7rUjG2aXiRtTIAXms9sm VRu7cmw= In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk This is a multi-part message in MIME format. --------------e8fAb8MQz13waLCeEt0aF1yY Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 2025-12-02 Tu 6:31 PM, Chao Li wrote: > >> On Dec 3, 2025, at 07:13, Tom Lane wrote: >> >> Chao Li writes: >>>> On Dec 3, 2025, at 06:51, Tom Lane wrote: >>>> In this case, I think pgindent is indirectly enforcing good style. >>>> I do not like omitting braces around anything that's more than one >>>> line; readers have to pay close attention to whether the code is >>>> doing what it was intended to. >>> For “one line”, do you mean only a single line of statement or one line statement plus one line comment? >> In my head, a comment and a statement are two lines, and so need >> wrapping braces as much as two statements would do. I realize that >> C compilers think differently, but for readability and modifiability >> reasons that's the approach I take. >> > Totally agreed. In my first job at Lucent Technologies, the coding standard was that braces should always be added even if a clause has only one line of code. I remember one of the explanations was like, if braces has been added, then later when a new line of code is added to the clause, there is only one line of diff, otherwise braces need to be added, so it would be 3 lines of diffs. > +1. One of the things I find particularly un-aesthetic is having some branches of an if statement with braces and some without. We have lots of cases of that, but I try to avoid it. cheers andrew -- Andrew Dunstan EDB:https://www.enterprisedb.com --------------e8fAb8MQz13waLCeEt0aF1yY Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit


On 2025-12-02 Tu 6:31 PM, Chao Li wrote:

On Dec 3, 2025, at 07:13, Tom Lane <tgl@sss.pgh.pa.us> wrote:

Chao Li <li.evan.chao@gmail.com> writes:
On Dec 3, 2025, at 06:51, Tom Lane <tgl@sss.pgh.pa.us> wrote:
In this case, I think pgindent is indirectly enforcing good style.
I do not like omitting braces around anything that's more than one
line; readers have to pay close attention to whether the code is
doing what it was intended to.

        
For “one line”, do you mean only a single line of statement or one line statement plus one line comment?
In my head, a comment and a statement are two lines, and so need
wrapping braces as much as two statements would do.  I realize that
C compilers think differently, but for readability and modifiability
reasons that's the approach I take.

Totally agreed. In my first job at Lucent Technologies, the coding standard was that braces should always be added even if a clause has only one line of code. I remember one of the explanations was like, if braces has been added, then later when a new line of code is added to the clause, there is only one line of diff, otherwise braces need to be added, so it would be 3 lines of diffs.


+1. One of the things I find particularly un-aesthetic is having some branches of an if statement with braces and some without. We have lots of cases of that, but I try to avoid it.


cheers


andrew

--
Andrew Dunstan
EDB: https://www.enterprisedb.com
--------------e8fAb8MQz13waLCeEt0aF1yY--