[TUHS] tabs vs spaces - entab, detab

Larry McVoy lm at mcvoy.com
Fri Mar 5 10:55:31 AEST 2021


On Thu, Mar 04, 2021 at 07:44:12PM -0500, John Cowan wrote:
> On Thu, Mar 4, 2021 at 2:10 PM emanuel stiebler <emu at e-bbes.com> wrote:
> 
> Does it help, if we differentiate with the type of text ?
> >
> > Assembler : Tabs = 8 spaces
> > (c, c++, pascal, java, etc.) : tabs = 4 spaces
> >
> 
> The Lisp community long ago standardized on 2-space indentation.

I used to be a 4 spaces are tabs guy but Sun beat that out of me.
Tabs are tabs and they are for a reason, though that reason is pretty
dead.  The reason was pretty printing listings, anything but tabs got
all screwed up.  But it has probably been a decade or more since I've
pretty printed anything, maybe two.  Old habits...

I developed my own use of 4 spaces, those are "continuation lines"

	if (some_stupidly_long_expression_that_goes_on_forever >=
	    this_never_happens_but_it_does_happen_when_deeply_nested) {
	    	statement;
		statement2;
		etc;
	}

But I'm weird, I hate

	if (expr) 
		statement;

I do

	if (expr) statement;

Curly braces are for more than one statement or I do do

	if (expr) {
		statement;
	} else {
		statement2;
	}

I also like perl so I do 

#define	unless(x) if (!(x))

because I think this reads better:

	FILE	*f;

	unless (f = fopen(argv[1], "r")) {
		perror(argv[1]);
		exit(1);
	}


More information about the TUHS mailing list