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

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

From
Stefan Beller <sbeller@google.com>
Date
Jul 14, 2017, 17:13 UTC
Message-ID
<CAGZ79kaFH5BXEsTEz55NbfhrJoWfutTVQi-bv3NpomCoK9OzWw@mail.gmail.com>
In-Reply-To
<xmqqlgnrq9qi.fsf@gitster.mtv.corp.google.com>
On Fri, Jul 14, 2017 at 9:11 AM, Junio C Hamano <gitster@pobox.com> wrote:
>  - I prefer to keep decl-after-statement out of our codebase.  I
>    view it as a big plus in code-readability to be able to see a
>    complete list of variables that will be used in a block upfront
>    before starting to read the code that uses them.
sounds good to me.
Show 6 quoted lines
>  - Corollary to the above, I do not mind to have a variable
>    declaration in the initialization clause of a for() statement
>    (e.g. "for (int i = 0; i < 4; i++) { ... }"), as the scoping rule
>    is very sensible.  Some of our "for()" statements use the value
>    of the variable after iteration, for which this new construct
>    cannot be used, though.
I might send a test balloon for this.
>    . // comments
I would think these are useful for two reasons:
(a) these seem to be used widely outside of these old-style project
  (git, gcc, kernel), such that most new contributors need to be told
  to avoid these which adds to the entry burden.
(b) recursive nesting of comments is possible. We may not need this
  in the final patch, but I sure use that in development. To comment out
  a whole function containing multiple comments I have to select all
  lines and prefix them with // currently. If all comments were //, I could
  put /* .. */ around the function, which seems easier. I just realize
  I can use #if 0 .. #endif though.
  (a) may be a concern, (b) not so much from the projects point of view.
>    . restricted pointers

That sounds like the ultimate micro optimization, but may be hard to reason about after a years of churn, so it may become hard to maintain.

>    . static and type qualifiers in parameter array declarators
That sounds equally arcane.
Show 5 quoted lines
> -- >8 --
> Subject: [PATCH] clean.c: use designated initializer
>
> This is another test balloon to see if we get complaints from people
> whose compilers do not support designated initializer for arrays.

This sounds as if it is applied on top of Jeffs test balloon patch, such that we do not need to re-iterate the criteria why to do it here, e.g. this code is always compiled and did not change a lot over the last couple month, so potentially easy to revert.

Thanks, Stefan

Previous: Junio C HamanoNext: Jeff King
Message 19 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.