Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hsxy2-0001i1-B7 for pgsql-hackers@arkaria.postgresql.org; Wed, 31 Jul 2019 23:25:10 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hsxy1-0002dc-2X for pgsql-hackers@arkaria.postgresql.org; Wed, 31 Jul 2019 23:25:09 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hsxy0-0002ZY-Ki for pgsql-hackers@lists.postgresql.org; Wed, 31 Jul 2019 23:25:08 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.92) (envelope-from ) id 1hsxxy-0007AI-Cq for pgsql-hackers@postgresql.org; Wed, 31 Jul 2019 23:25:07 +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 x6VNP1Of029535; Wed, 31 Jul 2019 19:25:01 -0400 From: Tom Lane To: Andres Freund cc: Alvaro Herrera , vignesh C , Pg Hackers Subject: Re: Unused header file inclusion In-reply-to: <20190731215314.tdlrqdgnd73do2ht@alap3.anarazel.de> References: <20190731203607.GA5260@alvherre.pgsql> <22389.1564606531@sss.pgh.pa.us> <20190731215314.tdlrqdgnd73do2ht@alap3.anarazel.de> Comments: In-reply-to Andres Freund message dated "Wed, 31 Jul 2019 14:53:14 -0700" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <29533.1564615501.1@sss.pgh.pa.us> Date: Wed, 31 Jul 2019 19:25:01 -0400 Message-ID: <29534.1564615501@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Andres Freund writes: > On 2019-07-31 16:55:31 -0400, Tom Lane wrote: >> Yeah. I seem to recall a proposal that nodes.h should contain >> >> typedef struct Foo Foo; >> >> for every node type Foo, and then the other headers would just >> fill in the structs, and we could get rid of a lot of ad-hoc >> forward struct declarations and other hackery. > That to me just seems objectively worse. Now adding a new struct as a > minor implementation detail of some subsystem doesn't just require > recompiling the relevant files, but just about all of pg. Er, what? This list of typedefs would change exactly when enum NodeTag changes, so AFAICS your objection is bogus. It's true that this proposal doesn't help for structs that aren't Nodes, but my sense is that > 90% of our ad-hoc struct references are for Nodes. > Right now we really have weird dependencies between largely independent > subsystem. Agreed, but I think fixing that will take some actually serious design work. It's not going to mechanically fall out of changing typedef rules. > The only reason the explicit forward declaration is needed in the common > case of a 'struct foo*' parameter is that C has weird visibility rules > about the scope of forward declarations in paramters. Yeah, but there's not much we can do about that, nor is getting rid of typedefs in favor of "struct" going to make it even a little bit better. regards, tom lane