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

Re: [PATCH 3/3] diff --stat: sometimes use non-linear scaling.

From
DRDavid Rientjes <rientjes@cs.washington.edu>
Date
Sep 27, 2006, 05:32 UTC
Message-ID
<Pine.LNX.4.64N.0609262216390.12560@attu2.cs.washington.edu>
In-Reply-To
<7vmz8lj3pl.fsf@assigned-by-dhcp.cox.net>
On Tue, 26 Sep 2006, Junio C Hamano wrote:
Show 6 quoted lines
> David Rientjes <rientjes@cs.washington.edu> writes:
> 
> > Again with the constant placement in a comparison expression.
> 
> I won't comment on this one.  See list archives ;-).
> 

I'm very familiar with the list archives and your support of writing relationals like 0 < x. It's a matter of taste. And since the large majority of programmers in any language write x > 0 instead, I think it's preferrable to write code that is in the style and taste of the majority.

Large software projects require a conformity in the style in which the code is written. Granted the git developer community is small, there is still a need for this confomity so that developers don't have to put up with the subtleties in the style of which individuals decide to code.

When I read "x > 0", my mind parses that very easily. When I read "0 < x", it takes me a few cycles longer. I think the goal of any software project is to not only emit efficient and quality code, but also code that can be read and deciphered with ease unless it's impossible otherwise.

Show 28 quoted lines
> What's happening here in this particular case is:
> 
> 	if the changes fits within the alloted width
> 		; /* we do not have to do anything */
> 	else if we are using non-linear scale {
>                	scale it like this
> 	}
> 	else {
>                	scale it like that
> 	}
> 
> so the code actually matches the flow of thought perfectly well.
> 
> I first tried to write it without "if () ;/*empty*/ else" chain
> like this:
> 
> 	if given width is narrower than changes we have {
>         	if we are doing non-linear scale {
>                 	scale it like this
>                 }
>                 else {
>                 	scale it like that
> 		}
> 	}
> 
> 
> It made the indentation unnecessarily deep.
> 

To change the code itself because of a hard 80-column limit or because you're tired of hitting the tab key is poor style. The idents are there for a purpose: it tells the reader that the code is inside a block. So when this conditional becomes a screen wide, I can understand it on the second screen and remember that I'm inside a conditional and not rely on the previous 'else' to jog my memory. C is not a whitespace-dependent language like Python, but since when did idents (which are there _solely_ for the purpose of helping the reader) become deprecated?

		David
Previous: Junio C HamanoNext: Junio C Hamano
Message 4 of 18 in “diff --stat: sometimes use non-linear scaling.”
  1. 3/3 diff --stat: sometimes use non-linear scaling.Junio C Hamano, Sep 27, 2006
  2. David RientjesSep 27, 2006
  3. Junio C HamanoSep 27, 2006
  4. David RientjesSep 27, 2006
  5. Junio C HamanoSep 27, 2006
  6. David RientjesSep 27, 2006
  7. Junio C HamanoSep 27, 2006
  8. David RientjesSep 27, 2006
  9. Johannes SchindelinSep 27, 2006
  10. Petr BaudisOct 6, 2006
  11. Johannes SchindelinSep 27, 2006
  12. Martin WaitzSep 27, 2006
  13. Linus TorvaldsSep 27, 2006
  14. Martin WaitzSep 28, 2006
  15. Junio C HamanoSep 28, 2006
  16. Andreas EricssonSep 29, 2006
  17. Johannes SchindelinSep 27, 2006
  18. SeanSep 27, 2006

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.