September 11, 2006
Stewart Gordon wrote:
> Walter Bright wrote:
> <snip>
>>> 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.
> 
> I'm not quite with you.  True, using spaces only is one way.  But if a given coder uses only '\t' to indent (as I do), what is there to lose?

What if you want to write:

	foo();	// comment
		// more comment

and have the comments line up?
September 11, 2006
Derek Parnell wrote:
> On Sun, 10 Sep 2006 11:13:11 -0700, Walter Bright wrote:
> 
>> 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.
> 
> Can one force other people to use "hard tabs"? Obviously no. So therefore I
> do not use them, I just use spaces.

That's one solution that works.
September 11, 2006
On Sun, 10 Sep 2006 20:03:39 -0400, Walter Bright <newshound@digitalmars.com> wrote:

> Stewart Gordon wrote:
>> Walter Bright wrote:
>> <snip>
>>>> 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.
>>  I'm not quite with you.  True, using spaces only is one way.  But if a given coder uses only '\t' to indent (as I do), what is there to lose?
>
> What if you want to write:
>
> 	foo();	// comment
> 		// more comment
>
> and have the comments line up?


<tab> foo(); <spaces> // comment
<tab>     <spaces>    // comment

match up tabs for indentation, use spaces for further alignment.
September 11, 2006
On Sun, 10 Sep 2006 17:03:39 -0700, Walter Bright wrote:

> Stewart Gordon wrote:
>> Walter Bright wrote:
>> <snip>
>>>> 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.
>> 
>> I'm not quite with you.  True, using spaces only is one way.  But if a given coder uses only '\t' to indent (as I do), what is there to lose?
> 
> What if you want to write:
> 
> 	foo();	// comment
> 		// more comment
> 
> and have the comments line up?

Exactly why I have problems with mixing the methods. One should only tabs or only spaces but never the two together. And if one uses tabs, then expect other people to complain about it eventually.  :-)

-- 
Derek
(skype: derek.j.parnell)
Melbourne, Australia
"Down with mediocrity!"
11/09/2006 10:47:26 AM
September 11, 2006
I meant, the prevailing style of DMD and Phobos - being "D's current style."

In an open source project, a lot of the time it's important to make your code available and convenient for others to view, edit, and contribute to.  That's part of the whole idea of open source.

You should always choose what's best for you, but keep in mind others as well.  There's usually a good, happy, middle place for everyone.

-[Unknown]


> On Sun, 10 Sep 2006 12:38:42 -0700, "Unknown W. Brackets"
> <unknown@simplemachines.org> wrote:
> 
>> 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.
> 
> That would be true if the compiler enforced the style rules. But
> Walter can only enforce his rules within his project - his right,
> common sense, and I'm sure his main intent.
> 
> My habit is to indent two spaces at a time. I've posted some snippets
> in that style. No-one has complained. But if I was contributing to the
> compiler or library, I'd expect to follow the rules.
> 
September 11, 2006
On Mon, 11 Sep 2006 10:33:21 +1200, "Regan Heath" <regan@netwin.co.nz> wrote:

>> It wasn't meant totally seriously.
>
>Neither was I :) Specifically the phrase "It's not evil, it's miss-understood" ;)

Yeah, missed that, sorry.

-- 
Remove 'wants' and 'nospam' from e-mail.
September 11, 2006
On Sun, 10 Sep 2006 17:03:39 -0700, Walter Bright <newshound@digitalmars.com> wrote:

>What if you want to write:
>
>	foo();	// comment
>		// more comment
>
>and have the comments line up?

Yes - among other vertical alignment issues, like large parameter lists. If I have a large expression, I'll probably use vertical alignment to emphasise the structure...

  varname = (   blahblahblah
             op (   blahblah
                 op blah
                )
            );

Could split it into multiple statements, but IMO this is usually clearer, as long as there's no repeated subexpressions.

Actually, Haskell even makes a similar vertical alignment style part of the language - it's called the 'offside rule' and it reduces the need for parentheses.

-- 
Remove 'wants' and 'nospam' from e-mail.
September 11, 2006
On Sun, 10 Sep 2006 20:14:49 -0400, "Chris Miller" <chris@dprogramming.com> wrote:

><tab> foo(); <spaces> // comment
><tab>     <spaces>    // comment
>
>match up tabs for indentation, use spaces for further alignment.

If either you or someone else has to refactor and reformat your code, at some point you're going to get spaces where you wanted tabs or tabs where you wanted spaces.

As soon as that happens, the world will come to a horrible end. There shall be plagues of rats, boils, plagues, and - worst of all - pot noodles. We, the space-indenting worthy shall be raised unto the sky, and we shall gloat down upon you, the evil tab-doers, and Perl.NET shall be loosed upon you, and great shall be your suffering.

So there.

-- 
Remove 'wants' and 'nospam' from e-mail.
September 11, 2006
Walter Bright wrote:
> 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.

         // comment
    foo();
         // comment
    bar + 4 *18 - foo();


never put '\t' after anything but a start of line.
September 11, 2006
On Mon, 11 Sep 2006 13:48:36 +0100, Steve Horne <stephenwantshornenospam100@aol.com> wrote:
> On Mon, 11 Sep 2006 10:33:21 +1200, "Regan Heath" <regan@netwin.co.nz>
> wrote:
>
>>> It wasn't meant totally seriously.
>>
>> Neither was I :) Specifically the phrase "It's not evil, it's
>> miss-understood" ;)
>
> Yeah, missed that, sorry.

My bad, I should have included a wink or smiley. It can be hard to convey your exact meaning in written form. I know I have to work harder on it, I think people take me too literally/seriously much of the time.

Regan