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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, 26 Sep 2006, Junio C Hamano wrote:

> David Rientjes <rientjes@xxxxxxxxxxxxxxxxx> 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.

> 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
-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]