git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v4 1/4] i18n: factorize more 'incompatible options' messages

From
Junio C Hamano <gitster@pobox.com>
Date
Feb 1, 2022, 17:58 UTC
Message-ID
<xmqqee4mfozc.fsf@gitster.g>
In-Reply-To
<f8202cc7-be5c-5efa-2a3b-987114356c6b@kdbg.org>
Johannes Sixt <j6t@kdbg.org> writes:
Show 14 quoted lines
>> Otherwise make it "static inline"?  Or just
>> 
>> #define die_for_incompatible_opt3(o1,n1,o2,n2,o3,n3) \
>> 	die_for_incompatible_opt4((o1), (n1), \
>> 				  (o2), (n2), \
>> 				  (o3), (n3), \
>> 				  0, "")
>> 
>> perhaps?
>
> Please no macros where they are not a clear advantage. Make it a
> function, either static inline, or out-of-line (the latter would be my
> personal preference in this case because the function is not called in a
> hot path).

In this particular case, my personal preference is actually a macro, since

 * there is no type safety lost
 * I find that it make it the most clear that 
   - the opt3 variant is a mere convenience wrapper, which does not
     even deserve an entry in the symbol table, of the real thing, and
   - our intention is to keep them closely in sync by not even
     giving future developers a pair of { braces }, in which they
     are tempted into writing extra code before or after calling the
     opt4 variant and make them diverge.
But it is not very strong preference.

A "static inline" wrapper would result in the same code as a macro, and I'd be almost equally happy with it. The code is almost already written, and fixing it is just a matter of inserting "static " in front. My preference between "static inline" and macro is not strong enough to insist on rewriting ;-)

An out-of-line wrapper has a slight disadvantage that it is not immediately obvious that one is a mere wrapper of the other thing by just looking at what is in the *.h file, but I am OK with it as well. If the original patch were written as an out-of-line wrapper, my preference is not strong enough to insist on rewriting, either.

Thanks.
Previous: Johannes SixtNext: Jean-Noël Avila
Message 36 of 41 in “Factorize i18n”
  1. 0/4 Factorize i18nJean-Noël Avila via GitGitGadget, Jan 22, 2022
  2. 1/4 i18n: factorize more 'incompatible options' messagesJean-Noël Avila via GitGitGadget, Jan 22, 2022
  3. Johannes SixtJan 24, 2022
  4. Phillip WoodJan 24, 2022
  5. Jean-Noël AVILAJan 25, 2022
  6. Johannes SixtJan 25, 2022
  7. 2/4 i18n: factorize "invalid value" messagesJean-Noël Avila via GitGitGadget, Jan 22, 2022
  8. Phillip WoodJan 24, 2022
  9. 4/4 i18n: transfer variables into placeholders in command synopsisJean-Noël Avila via GitGitGadget, Jan 22, 2022
  10. 3/4 i18n: remove from i18n strings that do not hold translatable partsJean-Noël Avila via GitGitGadget, Jan 22, 2022
  11. 0/4 Factorize i18nJean-Noël Avila via GitGitGadget, Jan 28, 2022
  12. 1/4 i18n: factorize more 'incompatible options' messagesJean-Noël Avila via GitGitGadget, Jan 28, 2022
  13. Johannes SixtJan 28, 2022
  14. Junio C HamanoJan 28, 2022
  15. Johannes SixtJan 29, 2022
  16. Jean-Noël AVILAJan 29, 2022
  17. Johannes SixtJan 29, 2022
  18. Ævar Arnfjörð BjarmasonFeb 1, 2022
  19. 2/4 i18n: factorize "invalid value" messagesJean-Noël Avila via GitGitGadget, Jan 28, 2022
  20. 3/4 i18n: remove from i18n strings that do not hold translatable partsJean-Noël Avila via GitGitGadget, Jan 28, 2022
  21. 4/4 i18n: transfer variables into placeholders in command synopsisJean-Noël Avila via GitGitGadget, Jan 28, 2022
  22. 0/4 Factorize i18nJean-Noël Avila via GitGitGadget, Jan 30, 2022
  23. 1/4 i18n: factorize more 'incompatible options' messagesJean-Noël Avila via GitGitGadget, Jan 30, 2022
  24. Johannes SixtJan 31, 2022
  25. Phillip WoodJan 31, 2022
  26. 2/4 i18n: factorize "invalid value" messagesJean-Noël Avila via GitGitGadget, Jan 30, 2022
  27. 4/4 i18n: transfer variables into placeholders in command synopsisJean-Noël Avila via GitGitGadget, Jan 30, 2022
  28. Phillip WoodJan 31, 2022
  29. Jean-Noël AvilaJan 31, 2022
  30. 3/4 i18n: remove from i18n strings that do not hold translatable partsJean-Noël Avila via GitGitGadget, Jan 30, 2022
  31. Johannes SixtJan 31, 2022
  32. 0/4 Factorize i18nJean-Noël Avila via GitGitGadget, Jan 31, 2022
  33. 1/4 i18n: factorize more 'incompatible options' messagesJean-Noël Avila via GitGitGadget, Jan 31, 2022
  34. Junio C HamanoJan 31, 2022
  35. Johannes SixtFeb 1, 2022
  36. Junio C HamanoFeb 1, 2022
  37. Jean-Noël AvilaFeb 2, 2022
  38. Johannes SixtFeb 2, 2022
  39. 2/4 i18n: factorize "invalid value" messagesJean-Noël Avila via GitGitGadget, Jan 31, 2022
  40. 3/4 i18n: remove from i18n strings that do not hold translatable partsJean-Noël Avila via GitGitGadget, Jan 31, 2022
  41. 4/4 i18n: fix some misformated placeholders in command synopsisJean-Noël Avila via GitGitGadget, Jan 31, 2022

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.