The D Style and tab sizes
Sean Kelly
sean at f4.ca
Sun Sep 10 15:22:21 PDT 2006
Regan Heath wrote:
> On Sun, 10 Sep 2006 11:13:11 -0700, Walter Bright
> <newshound at digitalmars.com> wrote:
>> 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.
>
> That's where the mistake/error has been made, NEVER use \t to line text
> up, ALWAYS use space.
>
> Tabs are for indentation only, or in other words, indenting the text
> essentially defining your left hand margin, nothing else!
>
> As long as you only use tabs to indent the left hand margin, and spaces
> to align text people can use any tab size they like and it will always
> work perfectly.
Try viewing Walter's code with a tab width of less than 8. Since his
indentation depth (4 chars) is less than the hard tab width, functions
typically look like this:
void fn()
{
int x;
for(;;)
{
blah blah;
}
}
I thought this was actually a deliberate indenting style until I changed
my tab width to 8 and suddenly most of the code became properly indented
(I say most because some places are indented with all spaces instead of
tabs--probably from submitted patches).
Sean
More information about the Digitalmars-d
mailing list