The D Style and tab sizes

Walter Bright newshound at digitalmars.com
Sun Sep 10 11:13:11 PDT 2006


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