[Haskell] Re: Use of tab characters in indentation-sensitive code

Andreas Rossberg rossberg at ps.uni-sb.de
Mon Jan 26 11:38:56 EST 2004


George Russell wrote:
> Graham Klyne wrote (according to Wolfgang Thaller, snipped):
>  > I think that compilers should issue a warning when indentation that
>  > determines the scope of a construct is found to contain tab characters.
> 
> In an ideal world, TAB characters would never have been put into ASCII, and
> this would be my preferred solution.  However, since there would be some 
> people
> who would object to such purity, a better alternative might be
> (a) to allow
> m TABs followed by n spaces
> at the start of lines.
> (b) to denote the indention of the line by the two numbers (m,n).
> (c) to give an error message when comparing two indentions 
> (m1,n1),(m2,n2) where
> neither m1<=m2,n1<=n2, nor m1>=m2,n1>=n2.
> 
> Incidentally Unicode allows far more possibilities for fun with 
> indentation (for example
> half-spaces, IIRC).

The most flexible but safe solution is to simply define the indentation 
as the sequence of indentation characters used. Two consecutive lines 
are indented consistently whenever one indentation is a prefix of the 
other. Hence you may freely mix different indentation characters, but 
you must be consistent across lines. Any decent editor should be able to 
ensure that.

With this solution, tab width is irrelevant and indentation may include 
whatever Unicode has.

	- Andreas

-- 
Andreas Rossberg, rossberg at ps.uni-sb.de

"Computer games don't affect kids; I mean if Pac Man affected us
  as kids, we would all be running around in darkened rooms, munching
  magic pills, and listening to repetitive electronic music."
  - Kristian Wilson, Nintendo Inc.



More information about the Haskell mailing list