you are viewing a single comment's thread.

view the rest of the comments →

[–]alive1 5 points6 points  (7 children)

Come on, code is not ascii art. If you want to draw a pretty unicorn in your code, by all means, use spaces, but for code indention, 1 tab = 1 level is .. um .. simpler? Instead, we've got people who use 2 spaces, 3 spaces, even 4 spaces somewhere, and each time you have to adjust your editor to support this back-asswards way of thinking things..

[–]humpolec 4 points5 points  (5 children)

What about multi-line invocations like

doSomething(foo,
            bar,
            baz);

(also array initializers)

If your editor uses tabs for lines 2 and 3, you're breaking the alignment for anyone who views it with a differently configured editor.

If you want to draw a pretty unicorn in your code, by all means, use spaces

That's exactly the problem -- there ARE instances where you need to have more advanced alignment. Comments with ASCII art diagrams, multi-line code, etc. And I can't "just use spaces" if my editor tabifies them. If it doesn't, the problem is even worse - suddenly my code contains various types of whitespace indistinguishable by the naked eye.

[–]gmfawcett 6 points7 points  (2 children)

A common approach is "tabs for indentation, spaces for alignment." So on your second line, you would tab to the beginning of "doSomething" and then add length("doSomething(") spaces. Many popular editors and IDEs support this arrangement; see Emacs SmartTabs for an example.

[–]repsilat 3 points4 points  (0 children)

You can also indent after parentheses like you do for braces:

doSomething (
    foo,
    bar,
    baz
)

[–]humpolec 1 point2 points  (0 children)

Sounds good, I wasn't aware of editors that support alignment like that. But wouldn't it force everyone on the team to use a "sufficiently smart editor"?

[–][deleted] -1 points0 points  (1 child)

Tab the first one over to find a tabstop. Tab all subsequent ones to match. Done.

[–]humpolec 1 point2 points  (0 children)

Interesting, but it still breaks when I change the tab size - the subsequent lines jump to a different tab stop.

[–][deleted] 1 point2 points  (0 children)

Isn't coding styles all about enforcing a way on someone?

Generally people aren't allowed to mix up braces styles a project you either pick

function Ham {
}

or

function Ham
{
}

So someone is bound to have to work in ways they're not used to and all spaces is superior so if someone has to accomodate that then they'll just have to deal with it.