Yay. Got referred here from elsewhere. Hooray for necro-posting!
Unfortunately, not everyone does. There's some people in the one-true-style thread I think who think it should be a heretical 2 spaces.
I am one of them. The people I really
don't understand are the ones who want to make it three
spaces. Apparently, the author of the forum software is one of them, considering how tabs are converted in code boxes here.
Rysto wrote:Can we all agree that anybody who mixes tabs and spaces for indentation will spend an eternity burning in hell, though?
I'd like to. Unfortunately, that consigns far too many innocent people who are horribly abused by their IDEs. The people who *really* need to be, shall we say, doing their part to avoid an infernal ice age, are the ones who thought it would be a good idea to implement this when doing the auto-indentation in the IDE (the most common style I've seen is: 4 spaces; 1 tab; 1 tab and 4 spaces; 2 tabs; etc.), presumably to save a few bytes in the source files or something.
Seriously. We're all relative nobodies, and a bunch of people in this thread understand perfectly well how tabs and spaces are supposed to be combined. Why can't we get an editor which behaves this way by default? (Vim has the nasty habit of using mixed tabs and spaces for alignment, even once you've convinced it to use tabs exclusively for indentation.)
I've actually ended up modifying my style to use "indentation instead of alignment where reasonable", like so:
Code: Select all
# I'm using a Python example because my Python code is
# most prone to containing complex *expressions*:
# --> represents a tab
-->x = [
-->-->for thing in funkyGenerator(
-->-->) if interesting(thing)
Anpheus wrote:C++ keywords sorted by length:
Somewhat pedantic: "TRUE" and "FALSE" are not C++ keywords. "true" and "false" are.
EvanED wrote:If someone using an 8-character stop has to deal with lines longer than 80 characters, then too bad; he can just set it to 4-character stops, and you're almost no worse off than if you had used spaces in the first place. (In fact, if this person is editing the code, he'd probably need to change settings anyway if you used spaces, lest he start inserting 8 of them where there should only be 4.) At least with tabs you've given him a choice of (1) not worrying about the 80-col limit, (2) saying that his preference for 8-space tabs overrides his preferences for 80-col limits and leaving the settings the same, and (3) saying his preference for 80-col limits overrides his preferences for 8-space tabs and changing to shorter tabs.
OTOH, if this kind of thing is a problem
in practice, it might indicate that the code is simply more complex than it ought to be.
That must sound weird coming from the 2-space-indent guy. But I'm not using that as an excuse for more deeply nested code; it just looks right
to me. I don't try to claim it's "right". It's just really really hard for me to imagine staring at really wide indents all the time and processing it OK.
masher wrote:The editor I use converts tabs to spaces. I use 3 spaces per tab, and I don't have to work on anybody else's code, so it's alright....
Aaaugh! It's one of THEM!
Arancaytar wrote:Seriously, if the editor takes care of auto-indentation anyway, there is no reason to use a character that doesn't even have a defined width.
You're missing the point. There is a perfectly good reason to use a character that doesn't have a defined width. That reason is: it doesn't have a defined width.
If two people are using this editor, and they want the indentation to be a different amount (and a quick survey of the thread indicates that this is very common), then if the editor has saved tabs to the underlying text file, it only has to adjust the tab stop used for the text control. If it has saved spaces, it has to apply heuristics and convert back and forth (if it doesn't convert both ways from a "reference", then the VCS will get polluted with whitespace changes, and it will also have to know who saved which version of the file in order to know how to convert the spaces). Then we notice that we simplify that code by letting the "reference" use 1 space indent, and actually letting that space be a different character from the spaces used for alignment (so that we don't need the fancy heuristics) - and gee, I wonder what character we'll pick?