Re: Acceptable/Best formatting of callbacks (for pluggable storage) - Mailing list pgsql-hackers

From Alvaro Herrera
Subject Re: Acceptable/Best formatting of callbacks (for pluggable storage)
Date
Msg-id 201901171505.b7oes2hzm3lj@alvherre.pgsql
Whole thread Raw
In response to Re: Acceptable/Best formatting of callbacks (for pluggable storage)  (Andres Freund <andres@anarazel.de>)
List 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


pgsql-hackers by date:

Previous
From: Alvaro Herrera
Date:
Subject: Re: ArchiveEntry optional arguments refactoring
Next
From: Tom Lane
Date:
Subject: Re: ArchiveEntry optional arguments refactoring