[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: OT - trivial programming language



Steve Lamb <grey@dmiyu.org> writes:

>     I set tab width to 4, align at 6.  Tab + 2 spaces.  Person sets his tabs
> to 8 the line is 10 spaces out, 4 spaces too far.  That's why people insist on
> a tab width of 8.  If tabs were immutable like that mixing tabs and spaces
> wouldn't be a problem.  It's not so it is.

My proposal was to use tabs and spaces in a way so that this does not
happen.  Consider the following piece of pidgin C:

if (some_condition) {
    if (another_condition) {
        foo(a,
            b);
/* ---->____| */

In the comment line I have tried to indicate how tabs and spaces are
used for the "b" line: the line starts with two tabs, one for each
level of nesting.  After this come spaces.

This means that, regardless of the tab width you choose, you will
always see the b below the a.

If the function name was foobar instead of foo, the "b" line would
still start with two tabs, but then you'd have 7 instead of 4 spaces.

I tried to coin the term "indentation" for the whitespace due to the
nesting level, and the term "alignment" for the spaces that make sure
that "b" and "a" line up.  And my proposal was to use tabs for
indentation and spaces for alignment.  If this was confusing, then
please accept my apologies.


It goes without saying that the nice property of giving code that
looks good in any tab width setting is lost as soon as you violate
that rule of using tabs and spaces.

Kai



Reply to: