[OT] Spaces/tabs (Was: simple display (from: GUI library for D))

Jonathan M Davis jmdavisProg at gmx.com
Mon Apr 11 22:13:58 PDT 2011


> "Jonathan M Davis" <jmdavisProg at gmx.com> wrote in message
> news:mailman.3412.1302578409.4748.digitalmars-d at puremagic.com...
> 
> >> On 04/11/2011 08:13 AM, Jonathan M Davis wrote:
> >> > They mix tabs and spaces. On some lines, they use spaces and on others
> >> > they use tabs.
> >> 
> >> Never seen this, not even once. Messing can only happen when one
> >> copy-pastes from modules using spaces.
> > 
> > As Steve pointed out, it frequently happens when you have multiple
> > developers
> > working on the same code. It may work with one developer who likes using
> > tabs,
> > but as soon as you get a mix of developers, you invariably get a mix of
> > spaces
> > and tabs unless _everyone_ involved is really careful, and that rarely
> > happens. It's just too easy to use spaces without realizing that someone
> > else
> > used tabs or even that you yourself are using spaces, depending on your
> > editor's settings.
> 
> That applies the other way around, too.
> 
> > Using only spaces and no tabs avoids the entire issue...
> 
> It avoid the issue *as well as* using only tabs for indentation.

No, because you _always_ have spaces. It's not like you stop using the 
spacebar just because your tab key is actually inserting tab characters. If 
you have tabs, then you're still going to have spaces. It's just a question of 
whether those involved in the project are disciplined enough to avoid ever 
using spaces for indenting. If, on the other hand, you only allow spaces, then 
you don't have the same concern about tabs being inserted. True, someone's 
editor could be set up poorly for either situation and insert spaces where 
they shouldn't or tabs where they shouldn't, but it's generally trivial to set 
up an editor to _never_ input tabs that it's easy to make it so that tabs are 
never used. However, the same can't be said of using tabs, because it's always 
possible to input spaces with the spacebar.

It's true that people occasionally end up inserting tabs in space-only 
environments, but in my experience, it's fairly rare. It's pretty much a 
guarantee, however, that _someone_ will insert spaces in an environment where 
it's supposed to be tabs.

There's not much point in arguing the matter. Some folks prefer tabs, and some 
prefer spaces, but I believe that it's most common for spaces to be preferred 
as far as style guides go, and they're generally less error-prone simply 
because it's easy enough to set up editors so that tabs are never used, and 
you can't do the same with spaces when you're using tabs for indentation.

- Jonathan M Davis


More information about the Digitalmars-d mailing list