On Tue, Jun 29, 2010 at 14:41, Reinier Zwitserloot <[email protected]> wrote:
> I don't understand the tabs v. spaces war. There's clearly a right
> answer:
>
> Tabs for indents. Spaces for spacing.
>
> Rule #1: A tab character can never occur in any source file, unless
> the previous character is (A) a tab, (B) the start of the file, or (C)
> a newline. Tabs anywhere else are by definition illegal and should
> have been done with spaces instead.
>
> Rule #2: Tabs are for _indents_ only. If you need to line things up
> vertically, you need spacing. Indent that line with however much
> indent it needs, then add spaces at the end of the indent tabs to line
> it up.

That's my thinking too! And yet I'm still an acolyte of "tabs are
evil". It's too easy to screw up in practice. I have little confidence
that most programmers are aware enough of what white space they are
typing to stick to these rules consistently.

(Also, but unrelatedly, Emacs' default behavior of mixing MOD 8 tabs
with spaces for indentation is probably the sickest thing I've ever
seen. I have my .emacs set to always use spaces.)

> For example, if you're one of those people who like to line up
> continued lines to a semantically logical place, you can do that.
> Something like this:
>
>        private int x = 10,
>                          y = 20;

The other problem with tabs is that they get spindled, folded and
mutilated by e-mail transport and the like.  The example quoted above
looks as if intended to illustrate this very point.

Any open source project taking submissions in the form of patches
would be foolish to standardize on tabs for indentation.

> is then done by tab-indenting both lines to whatever indent you need,
> then using exactly 12 spaces to line the 'y' up with the 'x' (12,
> because there are 12 characters in the text "private int ".

Just to throw a third option out there, have you ever had a look at
http://nickgravgaard.com/elastictabstops/ ?

// Ben

-- 
You received this message because you are subscribed to the Google Groups "The 
Java Posse" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/javaposse?hl=en.

Reply via email to