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

Re: [PATCH v2] cache_tree_find(): remove redundant checks

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 5, 2014, 17:57 UTC
Message-ID
<xmqqeh2gil55.fsf@gitster.dls.corp.google.com>
In-Reply-To
<xmqqr46himd1.fsf@gitster.dls.corp.google.com>
Junio C Hamano <gitster@pobox.com> writes:
Show 6 quoted lines
> Michael Haggerty <mhagger@alum.mit.edu> writes:
>
>> I really wish we could mix declarations with statements because I think
>> it is a big help to readability.
> ...
> Unfortunately, I think we are in violent disagreement.

After re-reading the above, I realize that my statement may have sounded a lot stronger than I intended it to. If our codebase allowed decl-after-stmt, that would change the equation and a different style might help readability somewhat.

If decl-after-stmt were allowed, the group of lines that declare variables at the beginning before the real logic begins do not even have to be there, and "if some variables have initialization that involve program logic that need to be read carefully, the declaration at the beginning no longer can be coasted over as boilerplate" complaint disappears. The entire block can become the logic, declaring variables as necessary at the point they are required, without having to have a separate decl at the beginning.

Note that I am not advocating to allow decl-after-stmt; I do not think the imagined readability benefit is worth it.

Previous: Junio C HamanoNext: David Kastrup
Message 8 of 11 in “cache_tree_find(): remove redundant checks”
  1. cache_tree_find(): remove redundant checksMichael Haggerty, Mar 4, 2014
  2. David KastrupMar 4, 2014
  3. Michael HaggertyMar 4, 2014
  4. David KastrupMar 4, 2014
  5. Junio C HamanoMar 4, 2014
  6. Michael HaggertyMar 4, 2014
  7. Junio C HamanoMar 4, 2014
  8. Junio C HamanoMar 5, 2014
  9. David KastrupMar 5, 2014
  10. Junio C HamanoMar 5, 2014
  11. [microproject idea]Junio C Hamano, Mar 4, 2014

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.