June 14, 2004
On Mon, 14 Jun 2004 08:44:14 -0700, stonecobra <scott@stonecobra.com> wrote:
> Caring about this issue is evil, IMHO.  Whoever wrote the code wrote the code, you are welcome to write code the way you do.  Code talks...
>
> My, what a lovely bikeshed you have :)
>
> Can we worry about D here, instead of coding standards?  Even if Walter were to untabify, he would untabify at 8 spaces per tab, which all of you would dislike.

Un-tabbifying is not the soln, using \t instead of 4 spaces is. If you have \t then your editor can decide how to display it. If you have \t you can easily convert every odd one into 4 spaces to print it, etc..

> Why not just live with the code that was written for you?

Sure, but, it'd be nice to be able to read it as well.

Regan

-- 
Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/
June 14, 2004
On Mon, 14 Jun 2004 10:05:32 +0100, Lars Ivar Igesund <larsivar@igesund.net> wrote:
> Tabs in source code is evil (IMNSHO).

IMHO they're better than spaces.

Regan

-- 
Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/
June 14, 2004
On Mon, 14 Jun 2004 11:25:12 -0700, stonecobra <scott@stonecobra.com> wrote:
>>> Even if Walter
>>> were to untabify, he would untabify at 8 spaces per tab, which all of
>>> you would dislike.
>>
>>
>> You've clearly not understood the issue. If he untabified at 8sp per tab, we
>> would be very happy indeed.
>
> I do understand the issue, but the people with 4 spaces/tab editors that use tabs to code with will be unhappy because the code is indented too much.

You do, this is exactly my point also.

>>> Why not just live with the code that was written for
>>> you?
>>
>>
>> We will, whether it looks nice and is readily comprehended or not. I raised the
>> issue to ease the task, in a small way, for many people. Cumulatively there will
>> be a lot of time spent arsing around trying to get the D sources into a form that
>> is readable. Almost all of that time will be better spent writing D libraries, or
>> D programs.
>>
>> Or do you not think readibility is a factor in understanding?
>
> I do think readability is a factor in understanding, which is why I prefer the VisualBasic way, where the editor re-writes every line of code to comply to a readability standard, whether you like it or not.

Sorry, this is evil, evil, and a 3rd time evil.

The same was done in Frontpage the html editor, the problem with it was, that it got re-written to use MS only methods which do not work in other web servers.

And it removed all my cgi replaceable tokens.

So it was basically useless.

So I use TextPad.

> But I am not going to tell people how to code to some common readability standard, especially when they are clearly against it and unlikely to change.  Hence the bikeshed comment.
>
> I apologize everyone, this will be my last post on the subject of tabs and spaces.

Don't appologise, your opinion is valid.

-- 
Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/
June 14, 2004
On Sun, 13 Jun 2004 23:34:15 -0700, Walter <newshound@digitalmars.com> wrote:
> "Regan Heath" <regan@netwin.co.nz> wrote in message
> news:opr9kj2ig85a2sq9@digitalmars.com...
>> What I *never* do is use both spaces AND tabs on one line, as this will
>> never look right except under the same conditions as I wrote it.
>
> Despite most programmers mixing the two (including me), your technique only
> works for leading tabs. Using tabs to line up, say, right hand comments (a
> common style) fails even if you eshew spaces.

You've got me backwards.. I specifically said I use spaces to line things up.

Regan.

-- 
Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/
June 14, 2004
On Mon, 14 Jun 2004 12:17:26 +0100, Stewart Gordon <smjg_1998@yahoo.com> wrote:
> Matthew wrote:
>
> <snip>
>> Aren't you just backing up my argument that you untabify your source before bundling. As it stands, it's not context-free, since it assumes tabstops are 8.
>>
>> There's no good saying that others are wrong, since there's a proliferation of editors that use soft tabs, set to the "scientifically optimal" 4. If you want your code to appear correctly irrespective of context, it needs to be untabified.
> <snip>
>
> Yes, most coding environments do seem to be set to a tab size of 4.
>
> Indeed, I would somehow doubt there to be any universal standard here. If anything, then I guess someone decided 8 would be a good number for his/her/its purposes, and various people followed suit.  OTOH, programmers felt that 8 was too wide, and the 4-space tab caught on in that community.  I don't know about the old Fortraners, when they had to indent every statement by 8 chars anyway....
>
> There are three options being discussed here...
>
> 1. Tabs only
> Pros:
> - disk space efficient
> - easy and painless to type
> - when viewed in an editor with customisable tab sizes, appears at the size the user finds most comfortable
> Cons:
> - when viewed at bigger tab size, long, deeply indented lines are more likely to fall off the screen
>
> 2. Spaces only
> Pros:
> - consistent display
> - some editors can auto-convert tabs to spaces, making this form easy to produce

or anyone can, trivially, with a small program.

> - layout preserved in situations where tab chars may not be transmitted/rendered properly
> Cons:
> - take up more disk space
> - tedious to type in primitive editors (e.g. Notepad)
> - harder to maintain by others who prefer tabs, if their tab width is different (e.g. two-space indentation seems to tend to come out of Emacs users....)
>
> 3. Tabs with space half-indentation
> Pros:
> - finer, more 'comfortable' indentation than some tab width hard-coded in certain contexts

do you mean "in an editor with hard coded tabstops of 8 spaces it looks nicer than tabs does"?

> - less tedious than all-space indenting in Notepad

this is also a con, if you re-word it as..
 - slightly more tedious than all-tab indenting in notepad.

> - slightly more compact on disk than all-space indenting

this is also a con, if you re-word it as..
 - slightly less compact on disk than all-tab indenting.

> Cons:
> - looks a mess/hard to follow in environments having different tab width


These lists are excellent.

It's important to nore that if "tabs only" is used it does not mean you cannot use spaces where you want/need to. I do this in msdev to align specific things like comments on columns to a static array of data etc. They stay aligned regardless of the tabstop as I do not mix spaces and tabs in doing it.

> OK, so option 2 has the most cons, but the first is fairly minor and the rest are somewhat dependent on other factors.  And I imagine most programmers don't edit their code in Notepad, which isn't very suited to   the task anyway.  The con of 1 isn't all that serious when you consider that people aren't all going to be viewing at the same window width anyway.  OTOH, when I try to maintain code written in technique 3, I invariably find myself 'tidying' the indentation so that it makes sense in my comfort settings.
>
> NTS, I prefer 1, and tend to release code with the tabs still in place.

This is my preference also.

>   But if I'm putting code on a web page, then I change them to spaces. When posting code to a newsgroup I don't seem to be consistent, and I'm not sure how different newsreaders handle tab chars...

Regan.

-- 
Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/
June 14, 2004
On Mon, 14 Jun 2004 22:43:41 +1000, Derek <derek@psyc.ward> wrote:
>>> "Ant" <Ant_member@pathlink.com> wrote in message
>>> news:caihjb$1714$1@digitaldaemon.com...
>>>> In article <caiaqb$ti1$1@digitaldaemon.com>, Walter says...
>>>> >Printers, the linux command prompt, the windows command prompt, the 
>>>> DOS
>>>> >command prompt, the RT-11 command prompt, TOPS-10 command prompt, 
>>>> every
>>> TTY
>>>> >I've used from ASR-33 to VT-100, html browsers, etc., all have tab 
>>>> stops
>>> at
>>>> >8. Programs that default to anything other than 8 should be 
>>>> abandoned.
>>>> >Programs that allow tab stops to be customized should be flogged.
>>>> >
>>>>
>>>> you are stuck in the past, sorry.
>>>
>>> Sorry, I'm using the latest Microsoft Explorer, the latest HP laser printer,
>>> the latest Windows XP, and Red Hat Linux 9. All have 8 character tab stops
>>> wired in <g>.
>>
>> They are also living in the past ;)
>> printer? printer? who prints things anymore? that's 20th century ;)
>>
>> But, that list doesn't contain a code editor.
>> All posters on this thread use tabs.
>
> Hmmm...actually I don't. I never use them anymore. Haven't for many, many
> years now. The SPACE character is a fixed width but the TAB is variable,
> depending on many factors. The default is nearly always 8 spaces, but as
> that can be changed by nearly every (modern) editor and printing program, I
> gave up trying to keep code lined up using tabs.

I see what you're saying.. what were you trying to line up?

I use tabs, and my code lines up all the time regardless of the tabstop used. The reason it lines up is that I never mix tabs and spaces. I can send someone an example if they want, it might help show what I mean.

In the somewhat rare event that I need to line something up with something else specifically i.e. comments on static table data,  I use spaces so that it will always line up no matter what tabstop is used.

>> inclusive the original poster that asked for spaces!
>> all of them redefine the tab stops.
>
> The editors I use (EmEditor and Code-genie) automatically insert the right
> number of spaces when I press the TAB key.
>
> Oh well, its good to have a variety of opinions. Keeps the mind active.

We're spoilt for choice.

Regan

-- 
Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/
June 14, 2004
> >> Even if Walter
> >>were to untabify, he would untabify at 8 spaces per tab, which all of you would dislike.
> >
> >
> > You've clearly not understood the issue. If he untabified at 8sp per tab, we would be very happy indeed.
>
> I do understand the issue, but the people with 4 spaces/tab editors that use tabs to code with will be unhappy because the code is indented too much.

Wrong. Go back to the earlier post describing the indentation scheme, and work it out again.

> >
> >
> >>Why not just live with the code that was written for
> >>you?
> >
> >
> > We will, whether it looks nice and is readily comprehended or not. I raised
the
> > issue to ease the task, in a small way, for many people. Cumulatively there
will
> > be a lot of time spent arsing around trying to get the D sources into a form
that
> > is readable. Almost all of that time will be better spent writing D
libraries, or
> > D programs.
> >
> > Or do you not think readibility is a factor in understanding?
>
> I do think readability is a factor in understanding, which is why I prefer the VisualBasic way, where the editor re-writes every line of code to comply to a readability standard, whether you like it or not. But I am not going to tell people how to code to some common readability standard, especially when they are clearly against it and unlikely to change.  Hence the bikeshed comment.
>
> I apologize everyone, this will be my last post on the subject of tabs and spaces.

I shall try and emulate your reticence. ;)


June 15, 2004
Regan Heath wrote:

<snip>
>> 2. Spaces only
>> Pros:
>> - consistent display
>> - some editors can auto-convert tabs to spaces, making this form easy to produce
> 
> or anyone can, trivially, with a small program.

Well, there are plenty of programs out there that aren't small.  D is supposed to be suited to million-line projects according to the docs.

>> - layout preserved in situations where tab chars may not be transmitted/rendered properly
>> Cons:
>> - take up more disk space
>> - tedious to type in primitive editors (e.g. Notepad)
>> - harder to maintain by others who prefer tabs, if their tab width is different (e.g. two-space indentation seems to tend to come out of Emacs users....)
>>
>> 3. Tabs with space half-indentation
>> Pros:
>> - finer, more 'comfortable' indentation than some tab width hard-coded in certain contexts
> 
> do you mean "in an editor with hard coded tabstops of 8 spaces it looks nicer than tabs does"?

Yes.  But also situations where code is merely displayed and/or transmitted, rather than edited, under the same constraint.

>> - less tedious than all-space indenting in Notepad
> 
> this is also a con, if you re-word it as..
>  - slightly more tedious than all-tab indenting in notepad.
> 
>> - slightly more compact on disk than all-space indenting
> 
> this is also a con, if you re-word it as..
>  - slightly less compact on disk than all-tab indenting.

Yes, I was kind of thinking that myself.  I guess that, on average, the number of spaces would outweigh the halving of the number of tab characters....

<snip>
> It's important to nore that if "tabs only" is used it does not mean you cannot use spaces where you want/need to. I do this in msdev to align specific things like comments on columns to a static array of data etc. They stay aligned regardless of the tabstop as I do not mix spaces and tabs in doing it.
<snip>

Yes, there's giving code a tabular layout.  And boxed comments.  Not to mention my tendency to indent subsequent lines of a statement by 2 spaces.

Stewart.

-- 
My e-mail is valid but not my primary mailbox, aside from its being the unfortunate victim of intensive mail-bombing at the moment.  Please keep replies on the 'group where everyone may benefit.
June 15, 2004
Oh no.. a holy war has ensued.

There's a braindead simple solution to this.  Here it is:

FOLLOW THESE RULES:
===================
1. USE TABS FOR INDENTATION
2. USE SPACES FOR ALIGNMENT


Follow those two rules and everyone will be happy when they view your code, regardless of their chosen tab display size (2, 3, 4, 8, ...).

I've trained my team to work like this.  It's painless, and every guy is happy, AND our code looks great.

--Steve
June 15, 2004
Stephen Waits wrote:

> FOLLOW THESE RULES:
> ===================
> 1. USE TABS FOR INDENTATION
> 2. USE SPACES FOR ALIGNMENT

Following up with an example (printf call intentionally contrived):

void func()
{
	int   x;         // x-value
	float y = 0.0f;  // y-value

	printf(
	       "x = %d, y = %f\n",
	       x, y
	      );
}

And here it is again, substitute tab characters with '^' and space characters with '_'.

void_func()
{
^int___x;_________//_x-value
^float_y_=_0.0f;__//_y-value

^printf(
^_______"x_=_%d,_y_=_%f\n",
^_______x,_y
^______);
}


Such a simple solution.  Easy to do, produces great looking code.

--Steve