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

Re: [PATCH] strbuf: use designated initializers in STRBUF_INIT

From
Junio C Hamano <gitster@pobox.com>
Date
Jul 12, 2017, 21:08 UTC
Message-ID
<xmqqd1951hye.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<87d195zcy0.fsf@gmail.com>
Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:
Show 14 quoted lines
> On Tue, Jul 11 2017, Junio C. Hamano jotted:
>
>> Just so that people do not misunderstand, it is not our goal to
>> declare that now you need a fully C99 compiler to build Git.
>> ...
>
> I think in the context of this desire Johannes Sixt's "Actually, I'm
> serious [about let's compile with c++]"[1] should be given some more
> consideration.
> ...
> Most of his patch is just avoiding C++ keywords, e.g. new -> wen, try ->
> try_, this -> this_, namespace -> name_space, template -> templ
> etc. It's going to be relatively easy to avoid a few keywords as
> variable names, especially if we set up CI for it via Travis.

I am not interested at all in building the binary I personally use with any C++ compiler, but I do not mind too much if people made it easier for other people to do so, but only if the did it the right way.

I do like the fact that we call two things we are comparing with a pair of matching words, 'old' and 'new'. When two variables or fields have certain relationship, they should be named with words that have constrasting meaning that explains what they are.

I would very much mind if a "let's make it buildable with C++" effort made the code compare 'old' and 'wen'. C++ is not that interesting to sacrifice the readability of the code. Don't invent non-words like wen; don't truncate a word like 'template' in the middle to 'templ' to make it unreadable and invite inconsistencies (e.g. "was it templ, templa, or something else?").

If a "let's make it buildable with C++" effort needs to avoid 'new', replace *both* 'old' and 'new' to a matching pair of words (perhaps 'pre' and 'post'? but it is making it worse by choosing a pair with different length. 'one' vs 'two' would be OK if there is no strong connotation that the 'old' side is always truly older in the function in question).

I would not mind the result of such an update that much. We already do use different pair of words in places that we could have used <old, new> after all.

Having to review too many updates like that in a single sitting would be annoying, though.

The same thing for where we use 'this'; if the existing code is contrasting 'this' with 'that', and if your C++ effort wants to replace 'this', you MUST replace 'that' as well so that we would still be contrasting a pair of variables appropriately named.

Previous: Ævar Arnfjörð BjarmasonNext: Johannes Sixt
Message 8 of 39 in “strbuf: use designated initializers in STRBUF_INIT”
  1. strbuf: use designated initializers in STRBUF_INITJeff King, Jul 10, 2017
  2. Ben PeartJul 10, 2017
  3. Jeff KingJul 10, 2017
  4. Ben PeartJul 10, 2017
  5. Mike HommeyJul 11, 2017
  6. Junio C HamanoJul 11, 2017
  7. Ævar Arnfjörð BjarmasonJul 12, 2017
  8. Junio C HamanoJul 12, 2017
  9. Johannes SixtJul 13, 2017
  10. Junio C HamanoJul 10, 2017
  11. Stefan BellerJul 10, 2017
  12. Junio C HamanoJul 10, 2017
  13. Andreas SchwabJul 10, 2017
  14. Johannes SixtJul 10, 2017
  15. Junio C HamanoJul 10, 2017
  16. Johannes SixtJul 10, 2017
  17. Junio C HamanoJul 10, 2017
  18. Junio C HamanoJul 14, 2017
  19. Stefan BellerJul 14, 2017
  20. Jeff KingJul 14, 2017
  21. Junio C HamanoJul 14, 2017
  22. Junio C HamanoJul 14, 2017
  23. objects: scope count variable to loopStefan Beller, Jul 19, 2017
  24. Brandon WilliamsJul 19, 2017
  25. Jeff KingJul 24, 2017
  26. Stefan BellerJul 24, 2017
  27. Jeff KingJul 24, 2017
  28. Ævar Arnfjörð BjarmasonJul 14, 2017
  29. Junio C HamanoJul 14, 2017
  30. Mike HommeyJul 14, 2017
  31. Jeff KingJul 15, 2017
  32. Jeff KingJul 11, 2017
  33. brian m. carlsonJul 11, 2017
  34. Stefan BellerJul 11, 2017
  35. brian m. carlsonJul 11, 2017
  36. Johannes SixtJul 11, 2017
  37. brian m. carlsonJul 12, 2017
  38. Johannes SixtJul 12, 2017
  39. Brandon WilliamsJul 10, 2017

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.