Re: Improve readability by using designated initializers when possible - Mailing list pgsql-hackers

From Jelte Fennema-Nio
Subject Re: Improve readability by using designated initializers when possible
Date
Msg-id CAGECzQQpiR5QcAxxuSrzAcj_KyLbE=mfbgM3Sbs8g8-ET=PteA@mail.gmail.com
Whole thread Raw
In response to Re: Improve readability by using designated initializers when possible  (Jeff Davis <pgsql@j-davis.com>)
Responses Re: Improve readability by using designated initializers when possible
List pgsql-hackers
On Thu, Feb 22, 2024, 23:46 Jeff Davis <pgsql@j-davis.com> wrote:

Am I missing something?

The main benefits it has are:
1. The order of the array doesn't have to exactly match the order of the enum for the arrays to contain the correct mapping. 
2. Typos in the enum variant names are caught by the compiler because actual symbols are used, not comments. 
3. The left-to-right order reads more natural imho for such key-value pairs, e.g. OCLASS_PROC maps to ProcedureRelationId. 

pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: bug report: some issues about pg_15_stable(8fa4a1ac61189efffb8b851ee77e1bc87360c445)
Next
From: Jeff Davis
Date:
Subject: Re: Improve readability by using designated initializers when possible