[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Request For Comments: 3-space indentation style
- From: Hisham <h@...>
- Date: Mon, 6 Jan 2014 19:42:21 -0200
On 6 January 2014 19:27, William Ahern <william@25thandclement.com> wrote:
> On Mon, Jan 06, 2014 at 11:03:33AM +0000, Craig Barnes wrote:
>> On 5 January 2014 20:45, William Ahern <william@25thandclement.com> wrote:
>> > Indentation and alignment are two separate issues. We can _all_ agree that
>> > blocks should be indented, just not what the width should be. Use tabs and
>> > _every_ can be made happy by setting their tab stop.
>> >
>> > If you prefer a particular alignment when wrapping statements, expressions,
>> > and comments, then align them--using spaces. It's far easier for people to
>> > deal with quirky alignments then it is to deal with quirky and annoying
>> > indentation. And because alignments can be very complex--with invariably
>> > corner cases that require you to violate your own rules--editors do a
>> > horrible job of reflowing alignments of complex statements, so better to
>> > just disable that feature (please!).
>> >
>> > If you use tabs for indentation and spaces for alignment, then when people
>> > change their tab stop your alignment will still magically work.
>> >
>>
>> Except that as soon as your code has tabs in it, all bets are off for aligning
>> anything. A tab is a variable-width character and is incompatible with
>> the notion of monospace alignment. It might seem to work so long as you
>> always view it in the same editor with the same tab width, but it'll surely
>> break as soon as someone views it with a different tab width.
>
> If you use tabs for indentation and spaces for alignment, then your tab stop
> is inconsequential. No matter your tab stop, anything you align within an
> indented block will stay aligned.
>
> Indentation always comes on the left-hand side. Anything you align inside of
> a block will always have the same number of tabs, and will always shift
> right or left as one block. It will all remain aligned correctly.
>
> For example, take an ASCII art picture. If you insert an equal number of
> tabs at the left, the picture will remain aligned, just shifted over. The
> tab stop won't magically take it out of alignment.
I think this is the level of attention that Marc LePage was alluding
to (when he said that average people just don't have it). Tabs for
indentation and spaces for alignment are great in theory but hard to
get right 100% of the time in practice. (The visual markers that some
IDEs put in tabs help, but not everyone likes to enable them, or to
use a graphical IDE for that matter.)
Even when not mixing tabs and spaces sometimes the wrong one slips --
I modified my console-based text editor so it checks if the file
contains tab characters; if it doesn't, then the Tab key emits spaces;
if it does, then the Tab key emits tab *and* I get a message saying
"TABS" in the status bar. (I can press Ctrl-T to toggle the behavior
of my Tab key.) Sometimes when applying patches sent by contributors
to my (spaces-only) source code, it is the "TABS" warning that tells
me to go there and clean up the indentation. If it wasn't for that, I
would most likely miss them.
-- Hisham
- References:
- Request For Comments: 3-space indentation style, immerrr again
- Re: Request For Comments: 3-space indentation style, Tim Hill
- Re: Request For Comments: 3-space indentation style, David Given
- Re: Request For Comments: 3-space indentation style, steve donovan
- Re: Request For Comments: 3-space indentation style, Hisham
- Re: Request For Comments: 3-space indentation style, Jorge
- Re: Request For Comments: 3-space indentation style, Andrew Starks
- Re: Request For Comments: 3-space indentation style, phlnc8
- Re: Request For Comments: 3-space indentation style, William Ahern
- Re: Request For Comments: 3-space indentation style, Craig Barnes
- Re: Request For Comments: 3-space indentation style, William Ahern