LWN.net Logo

Eight character tabs

Eight character tabs

Posted Oct 31, 2012 11:40 UTC (Wed) by etienne (subscriber, #25256)
In reply to: Eight character tabs by nix
Parent article: Thoughts on the ext4 panic

> spaces are nice and uncontroversial and always work. Tabs don't.

Well, have you ever used an editor with variable width font?
Why - maybe because text is easier to read...
Then, you can only use tabs to align stuff - unless that is the beginning of the line. If you comment a line using "//" at its beginning stuff stay aligned.
I do not want a hard limit on the number of chars, because not all chars are the same width...

Also, in some case (long debug printf() line), breaking the long line makes the structure of the function more complex than it really is; just tell you editor not to wrap and just ignore the end of the printf() line - it is just a printf()!


(Log in to post comments)

Eight character tabs

Posted Oct 31, 2012 13:21 UTC (Wed) by nix (subscriber, #2304) [Link]

Variable-width fonts don't work at all for most programming languages for the reasons you state. I actually tried to use a variable-width font only for comments for a while, but it really messes up ASCII-art, and the places where you find ASCII-art in comments are generally the places where the code is complex enough to *need* it, and you don't want to have difficulty piled on by interpreting proportional-font damage too.

Eight character tabs

Posted Oct 31, 2012 17:08 UTC (Wed) by tialaramex (subscriber, #21167) [Link]

printf() - a function famous for never having been implicated in any complicated security bugs. Oh wait.

No, thanks all the same but I'd rather actually see the code I'm maintaining and not trust that the bits I can't see aren't important.

I like the ASCII control characters, but most of them don't belong in my source code and that includes U+0009 TAB. Use soft tabs, set the continuous integration software to barf on hard tabs in source code, along with mysterious trailing whitespace and similar sins.

Eight character tabs

Posted Oct 31, 2012 18:52 UTC (Wed) by nix (subscriber, #2304) [Link]

I don't understand your debug printf() comment at all. You can always break a printf() line, even in the format string, with string literal concatenation.

Eight character tabs

Posted Nov 1, 2012 9:41 UTC (Thu) by ncm (subscriber, #165) [Link]

Me, I've never understood why people insist that printf format strings should be indented at all. I push them to the left margin, and it brings no confusion, but much clarity.

Eight character tabs

Posted Nov 1, 2012 12:06 UTC (Thu) by etienne (subscriber, #25256) [Link]

But most of the time you want to understand the structure of the function you are about to modify, even if you have (probably commented) printf's showing that you entered the function with those parameters, that you are calling that other function with those parameters, what is the value of each of the fields of that structure...
Having 3/4 lines of code with no algorithm meaning does not help to see the structure of the code and is difficult to comment/uncomment at once; it is easier to tell your editor not to wrap lines and so not display the end of those (probably commented) lines.
Obviously you can write the functions print_mystruct_and_cpt(), print_mystruct_and_idx(), ... that you call only once in a commented out block.
Linux source do not have much "logging" lines, so it is not a real problem there.

Copyright © 2013, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds