Re: Acceptable/Best formatting of callbacks (for pluggable storage)

From: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>
To: Andres Freund <andres(at)anarazel(dot)de>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Acceptable/Best formatting of callbacks (for pluggable storage)
Date: 2019-01-17 15:05:50
Message-ID: 201901171505.b7oes2hzm3lj@alvherre.pgsql
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 2019-Jan-11, Andres Freund wrote:

> Just as an example of why I think this isn't great:

Hmm, to me, the first example is much better because of *vertical* space
-- I can have the whole API in one screenful. In the other example, the
same number of functions take many more lines. The fact that the
arguments are indented differently doesn't bother me.

> typedef Size (*EstimateDSMForeignScan_function) (ForeignScanState *node,
> ParallelContext *pcxt);
> typedef void (*InitializeDSMForeignScan_function) (ForeignScanState *node,
> ParallelContext *pcxt,
> void *coordinate);
> typedef void (*ReInitializeDSMForeignScan_function) (ForeignScanState *node,
> ParallelContext *pcxt,
> void *coordinate);
> typedef void (*InitializeWorkerForeignScan_function) (ForeignScanState *node,
> shm_toc *toc,
> void *coordinate);
> typedef void (*ShutdownForeignScan_function) (ForeignScanState *node);
> typedef bool (*IsForeignScanParallelSafe_function) (PlannerInfo *root,
> RelOptInfo *rel,
> RangeTblEntry *rte);
> typedef List *(*ReparameterizeForeignPathByChild_function) (PlannerInfo *root,
> List *fdw_private,
> RelOptInfo *child_rel);
>
> that's a lot of indentation variability in a small amount of space - I
> find it noticably slower to mentally parse due to that. Compare that
> with:
>
> typedef Size (*EstimateDSMForeignScan_function)
> (ForeignScanState *node,
> ParallelContext *pcxt);
>
> typedef void (*InitializeDSMForeignScan_function)
> (ParallelContext *pcxt,
> void *coordinate);
>
> typedef void (*ReInitializeDSMForeignScan_function)
> (ForeignScanState *node,
> ParallelContext *pcxt,
> void *coordinate);
>
> typedef void (*InitializeWorkerForeignScan_function)
> (ForeignScanState *node,
> shm_toc *toc,
> void *coordinate);
>
> typedef void (*ShutdownForeignScan_function)
> (ForeignScanState *node);
>
> typedef bool (*IsForeignScanParallelSafe_function)
> (PlannerInfo *root,
> RelOptInfo *rel,
> RangeTblEntry *rte);
>
> typedef List *(*ReparameterizeForeignPathByChild_function)
> (PlannerInfo *root,
> List *fdw_private,
> RelOptInfo *child_rel);
>
> I find the second formatting considerably easier to read, albeit not for
> the first few seconds.

--
Álvaro Herrera https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2019-01-17 15:23:39 Re: ArchiveEntry optional arguments refactoring
Previous Message Alvaro Herrera 2019-01-17 15:02:16 Re: ArchiveEntry optional arguments refactoring