Use of tab characters in indentation-sensitive code

Wolfgang Thaller wolfgang.thaller at gmx.net
Sat Jan 24 18:29:46 EST 2004


Graham Klyne wrote:

> I think that compilers should issue a warning when indentation that
> determines the scope of a construct is found to contain tab characters.

I'd say, when it "is found to contain a mixture of tab and space 
characters".
I have successfully written a lot of Haskell code that uses tabs 
*exclusively* - in that case, the meaning of the program *doesn't* 
depend on how the tab characters are interpreted.
IMHO, there should only be warnings about tabs when their size makes a 
difference to the meaning of the program, as shown in the examples 
below:

let
<spaces>x = 1
<TAB--->y = 1	-- warning

let
<TAB--->x = 1 -- OK
<TAB--->y = 2 -- OK
<spaces>z = 3 -- warning

a = let x = 1
         y = 2 -- OK
	in ...

b = let x = 1
<TAB--->y = 2 -- warning
     in ...

There are many editors that automatically mix tabs and spaces in 
indentation (and I don't like that - what's it good for?), but some 
people will certainly want to continue to use them, so I'm not sure if 
adding warnings like these would be acceptable to them.

Cheers,

Wolfgang



More information about the Haskell mailing list