Thread (95 messages) flat view 95 messages, 33 authors, 2016-06-15

Re: On Tabs and Spaces

From: Linus Torvalds <torvalds@linux-foundation.org>
Date: 2016-06-15 22:43:42


On Tue, 16 Oct 2007, Michael Witten wrote:
On 16 Oct 2007, at 8:45:51 PM, Linus Torvalds wrote:
quoted
And is it really so unreasonable to just say "8-character tabs are the
gold standard"?
It's unreasonable not to list that anywhere.
Heh.

I was sure we had a "CodingStyle", but it turns out that no, we don't, and 
yes, the 8-tab assumption is implicit in (a) the kernel rules (which git 
started out following for obvious reasons, and which *does* have 
documentation making this very explicit indeed) and (b) those few places 
where you can actually see it in the result.

So maybe it should be made explicit. You can see the effect right now by 
doing

	git grep -1 '	 ' *.c

(again, that regex is a "tab+space", although it's not obvious) and then 
looking for places where we line up things in ways that simply wouldn't 
have worked if it wasn't a 8-wide tab, ie things like

	...
	check_all_attr = xrealloc(check_all_attr,
				  sizeof(*check_all_attr) * attr_nr);
	..
	read_tree_recursive(args->tree, args->base, plen, 0,
			    args->pathspec, write_zip_entry);
	..

where the arguments wouldn't line up for anything but 8-char-wide tabs.

(But the code is certainly *readable* with other tab sizes, so it's not 
like this makes it impossible to work if somebody has a 4-space tab, it 
just means that such people can get odd effects - but they may not even 
realize that others see things line up!)

		Linus
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help