The D Style and tab sizes

Unknown W. Brackets unknown at
Sun Sep 10 12:38:42 PDT 2006

Many programmer's text editors or IDEs I've worked with use a default 
tab size of 4.  For example, Microsoft Visual Studio and Macromedia 
Dreamweaver use 4.

In web development, Dreamweaver is pretty much the standard, on Windows. 
  In C++, Visual Studio is.

In these editors, by default, the code looks entirely and completely 
unreadable.  However, code I write always looks readable and 
understandable in all editors, including nano, kate, etc. which use 8 as 
a default tab size.

This is because I conform to the following standards:

   - never line things up with tabs, except from the gutter.
   - never line things up with tabs against non-tab characters.
   - always use exactly one tab character per indentation level.

Honestly, when actual tab characters appear in the source, the above 
style is the prevailing style.  People who like otherwise typically use 
spaces only.

Saying that 8 is common and everywhere is simply incorrect.  Even with 
the editors that use 8 as a default, a large portion of programmers set 
it to 4, or even 3.

Whether I'm using a screen width of 1024, 1152, 1280, or 640... I should 
be able to choose how much screen real-estate is eaten by indentation. 
In D's current style, you are forcing a width on them: you believe that 
indentation must be 4 spaces, and so everyone must conform to that.  If 
someone prefers 8 spaces, 3 spaces, or 6 spaces... too bad.  Sucks to be 
them.  They have to live with YOUR style.

Very nice.  I'm glad the D compiler and language was not written the 
same way.  No one would use it.  At least with it, I can program in the 
style I wish to.  I'm not forced to follow some uncommon convention.


> Thomas Kuehne wrote:
>> Walter Bright schrieb am 2006-09-10:
>>> Stewart Gordon wrote:
>>>> 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.
>> What editor/IDE are you using?
>> gedit(GNOME), kedit(KDE) and vi/nano(shell) are all basic editors and
>> all have a way to set the display with of "\t" characters. Microsoft's
>> Notepad is probably the only default editor incapable of changing the
>> display with of "\t".
> That's true, but is not the problem. Consider:
>     foo();             // comment
>     bar + 4 *18 - foo();    // comment
> Suppose \t's are used to line up the comments. There is no way to have 
> them stay lined up if the strides of \t's change.
> I started with teletypes (ASR-33's). Moved on to Decwriters, Hazeltine 
> terminals, ADDs terminals, Diablo 630's, FX-80s, IBM PCs, DOS, Windows, 
> CPM-86, OS/2, HP laserprinters, Linux, NT, XP, HTML rendering, 
> Thunderbird email, etc.
> One thing they *all* had in common was 8 character hard tabs. Sure, in 
> any particular editor or environment, you can change the hard tab to be 
> 3, 4, or whatever, but as soon as your source leaves that environment, 
> it's screwed up.
> If you have a closed source project, that's no problem. But if it's part 
> of the D open source world, it'll be distributed to every type of 
> device, and the only thing in common will be 8 character hard tabs.
> Furthermore, if you're working with D and source that has had many 
> different hands working on it, do you want to change your environment's 
> hard tab settings every time you switch files? I don't.

More information about the Digitalmars-d mailing list