The D Style and tab sizes

Walter Bright newshound at digitalmars.com
Sat Sep 9 18:32:13 PDT 2006


Stewart Gordon wrote:
> http://www.digitalmars.com/d/dstyle.html
> 
> "Adhering to the D Style, however, will make it easier for others to 
> work with your D code and easier for you to work with others' D code."
> 
> "# Hardware tabs are at 8 column increments.
> # Each indentation level will be four columns."
> 
> Firstly, what is a "hardware tab"?

The \t character.

> Secondly, these two quotations seem contradictory.

Soft tabs and hard tabs aren't the same, although they are often confused.

> Making your code come out a mess in any editor that isn't configured 
> with a tab size of 8 is certainly not going to make it easier for others 
> to work with your D code.  On the contrary, it is much easier if people 
> can read your code regardless of how their editors are configured.
> 
> Most programmers, at least AFAIK, will decide on an indentation size 
> that they feel comfortable with and configure their editors to use this 
> as the tab size.  Of course, there will be some who indent with spaces, 
> not tabs, and some whose editors (either by user pref or by being 
> hard-coded to) automatically convert all tabs to spaces, but that's an 
> aside.
> 
> AFAIC, people who use tabs but indent by half a tab at a time are 
> painting themselves into a corner.  We should aim to write code that'll 
> be readable in any editor, whatever its tab size setting.

There's no way to do that and have hard tabs. The only way to achieve 
that is by using spaces only. Using spaces only is one way to conform to 
the D style guide.



More information about the Digitalmars-d mailing list