[NCLUG] Looking at programming languages...

Bob Proulx bob at proulx.com
Thu Jan 17 15:19:54 MST 2008


Duncan McGreggor wrote:
> Walker, Philip M (Optical Storage) wrote:
> > the indentation relies on the assumption that tabs (if present) are 
> > unambiguously equivalent to 8 spaces.
> >
> >Of course, that assumption is not valid unless your editor is configured 
> >that way
> 
> I don't know of any python programmer that uses 8 spaces for indent. I
> use 4 (with vim). The twisted python coding standard dictates 4. What's
> more, the official python coding standard
> (http://www.python.org/dev/peps/pep-0008/) suggests 4, saying that 8
> should only be used if necessary (e.g., legacy code).

You are confusing TABs with indention.  Those are two completely
separate concepts.  One does not dictate the other.

TABs (HT chars) expand to the next modulo eight column position.
Using any other expansion leads to incompatibility.  In order to
change this all use of HT chars in the past, present and future would
need to adopt a new standard.  Since that is not possible it will
never happen.  Therefore don't try to fight it.  Simply accept that
TABs expand to the next eighth column position.

If you wish to use a different indention and to configure your editor
to indent to a custom indention column when the Tab Key is pressed
that is both fine and typical.  What happens when the Tab Key is
pressed is independent and unrelated to the expansion of TAB
characters in the file.

I personally use an indention level of two most of the time.  This has
nothing to do with the expansion of TABs to eight column tabstops.
In Emacs I use the default GNU indention styles.  In vi/vim I use the
following configuration:

  softtabstop=2
  shiftwidth=2

Fun comment in the Linux kernel Documentation/CodingStyle file by
Linus Torvalds:

  Tabs are 8 characters, and thus indentations are also 8 characters.
  There are heretic movements that try to make indentations 4 (or even
  2!)  characters deep, and that is akin to trying to define the value
  of PI to be 3.

Bob



More information about the NCLUG mailing list