OT: Indent-sensitive languages again (was: Docs: Section on local variables)

Stewart Gordon smjg_1998 at yahoo.com
Wed Apr 25 17:28:15 PDT 2012


On 25/04/2012 12:30, Stewart Gordon wrote:
> On 21/04/2012 17:26, Andrej Mitrovic wrote:
> <snip>
>> Next thing you know the compiler will start warning me when I indent
>> my code with uneven number of spaces!
>
> Or more usefully, warn if you have a mishmash of tab and space indentation.
>
> How do indent-sensitive languages (Haskell, Python, whatever else) deal with mixed
> tab/space indentation, for that matter?

Just found out
http://urchin.earth.li/~ian/style/haskell.html
http://www.secnetix.de/olli/Python/block_indentation.hawk
that both Haskell and Python uses a tab size of 8 characters.  Personally, I think they 
should error if the meaning of a section of code depends on the tab size.

OTOH, YAML avoids the issue in the strictest way possible: forbidding tab characters.  I 
wonder if there are other languages that require you to indent with tabs.

But one possible design for languages like these is to allow indentation to be either 
entirely spaces or entirely tabs, but not a mixture.  This would also be a good way for 
linters for a variety of languages to behave.

Another way would be to allow tabs, spaces or a mixture, with the only restriction being 
that a given block must be consistently indented with the same sequence of tabs/spaces.

Stewart.


More information about the Digitalmars-d-learn mailing list