public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Linus Torvalds <torvalds@linux-foundation.org>
To: Ingo Molnar <mingo@elte.hu>
Cc: Andy Whitcroft <apw@canonical.com>,
	Roland McGrath <roland@redhat.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] ptrace: checkpatch fixes
Date: Thu, 9 Apr 2009 08:00:18 -0700 (PDT)	[thread overview]
Message-ID: <alpine.LFD.2.00.0904090750370.4583@localhost.localdomain> (raw)
In-Reply-To: <20090409030440.GA9169@elte.hu>



On Thu, 9 Apr 2009, Ingo Molnar wrote:
> 
> We should perhaps introduce an too-deep-indentation warning: any 
> function with "[;{}]$" lines of 4 tabs in a row is already suspect 
> IMHO. At 5 it's definitely crazy and ugly.
> 
> This would be a very efficient function-length reductor: it cannot 
> be worked around via line wraps.

People would start using spaces to try to work around it instead, which is 
a worse cure than the problem.

Also, the thing is, a long _individual_ line is not a problem even if you 
have a 80-column terminal. Sane editors will have a marker for "this line 
continues", and even if you have an insane editors that doesn't do that, 
it's pretty obvious - and if you really care about the end of that 
_particular_ line (most of the time you don't), you can just move to that 
line.

So if you have a couple of long lines occasionally, that's not a huge 
problem. In fact, that's why I hate splitting lines so much: the "false 
indentation" that a line split causes is generally much more confusing 
visually (not so much in something like a function header, but often very 
much so inside the code itself).

> It would also be wonderful to warn about bad 80 columns 'fixes' - 
> i've seen way too many perfectly fine cleanups damaged by ugly 
> line-wrapping solutions.

The thing is, it's very hard to warn about those. You need more 
understanding than your average perl-script can ever get.

> We could also up the limit to 90 or 100 columns. My terminals are at 
> 90 columns and that's still pretty ergonomic.

I tend to start out with a 80x24 and just resize it, and end up at some 
random value. It's usually in the 90x40 range for me. But I do want the 
code to be perfectly _readable_ in a 80x24 window, and quite frankly, if 
you look at something like kernel/ptrace.c, it really generally is.

So sure, that "int ptrace_readdata()" line is longer than that, and won't 
show completely. But you don't miss any huge glaring code issues even in 
the truncated mode. In fact, if I try to use 80x24, my biggest issue will 
inevitably be not the 80 part, but the 24 part. 

IOW, I think there is much more reason to hate long _functions_ than there 
is reason to hate long lines. Both cause you to scroll. The long function 
where there is action over more than 24 lines happens a lot more.

					Linus

      parent reply	other threads:[~2009-04-09 15:03 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-04-08  6:21 [PATCH] ptrace: checkpatch fixes Roland McGrath
2009-04-08  7:26 ` Sergio Luis
2009-04-08 12:50   ` Roland McGrath
2009-04-08 20:49     ` Sergio Luis
2009-04-08 17:19 ` Linus Torvalds
2009-04-08 19:57   ` Christian Borntraeger
2009-04-08 20:44     ` Linus Torvalds
2009-04-09  3:04   ` Ingo Molnar
2009-04-09  8:46     ` Miles Bader
2009-04-09 15:00     ` Linus Torvalds [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.LFD.2.00.0904090750370.4583@localhost.localdomain \
    --to=torvalds@linux-foundation.org \
    --cc=akpm@linux-foundation.org \
    --cc=apw@canonical.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=roland@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox