in reply to Re: bloated 'if' formatting
in thread bloated 'if' formatting

Not to start a format war, but I've never understood the tabs == bad camp. There are times when using tabs is foolish (mostly, intra-line aligntment), for example:

$opt_a = 1; # this is option a $obt_hoo = 1; # this is option b

All the whitespace there should be spaces, not tabs.

On the other hand, I love it when code I maintain uses tabs for leftmost indentation. This is because I know many people who like an 8-space indent, where as I (for example), much prefer a 4-space indent. I have colleagues that also like a 2-space indent (!). By using tabs for left-side indents, we can all have our way by simply configuring our editor.

What's the argument against doing this?

In the case at hand, I would do:

if ( condition 1 && condition 2 && condition 3 ... ) { code to be executed } #/ short desc of if code, if needed. else { else-block code } #/ short desc of else code, if needed.
<-radiant.matrix->
A collection of thoughts and links from the minds of geeks
The Code that can be seen is not the true Code
"In any sufficiently large group of people, most are idiots" - Kaa's Law

Replies are listed 'Best First'.
Re^3: bloated 'if' formatting
by Nkuvu (Priest) on Oct 06, 2005 at 19:02 UTC
    I have to admit, the primary reason I dislike tabs is because most of the time I find tabs in a file, they're mixed in with spaces. So you get inconsistent indentation, based on tab widths. I've also seen too many instances of tabs in intra-line alignment, as you mentioned. Depending on tab widths, the columns may or may not line up.

    Since I've seen more misuses of tabs than decent uses of tabs, it's pretty easy to pigeonhole them into the "bad style" camp. It's really a very mild dislike, to tell the truth.

    And personally I prefer a 4 space indent for real code (i.e., code in my editor) but often I'll drop that to a 2 space indent when posting code online.

Re^3: bloated 'if' formatting
by Perl Mouse (Chaplain) on Oct 07, 2005 at 08:30 UTC
    That's a nice idea, but that would only work if windows aren't bounded horizontally. Think about it.

    Suppose you are using a 4-character indent. You are using tabs for indentation, using a 4 character tabstop. Inside a subroutine you have an for loop, and inside its body you have a 66 character statement. On your screen, the line ends in column 74.

    Now you give the code to someone who also uses 4 character wide indent, but he's using holding to the old mantra "don't change your tabstops" - his tabstops are 8 characters. Now the code he looks at not only has indents much wider than he's used to, the line that ended in column 74 on your screen will end in column 82 on his screen. Which, given a standard width of 80 characters means the code will be wrapped.

    Tabs are evil, and tabstops other than 8 even more so. But if everyone is using tabstops of the same length, you might as well use spaces.

    Perl --((8:>*
      Which, given a standard width of 80 characters means the code will be wrapped.

      Geez. I last used an 80 character wide screen back around 1984. Auspicous year. That was an ADM 3+. Next I used a VT100 which handle 132. Around 1987, I moved over to a PC with a EGA screen that also handle 132. And after that a 3279G which could handle 4 48x132 sessions tiled.

      The last time I used a *nix system, it was remotely via PC-based terminal emulator and I frequently used SCREEN to run four terminal sessions in a window, and from memory each of those four tiled sessions was over 80 characters wide. When I ran one session full screen it was something 200 x 72.

      What is this fixation with the 1970s and 24x80?


      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
      "Science is about questioning the status quo. Questioning authority".
      The "good enough" maybe good enough for the now, and perfection maybe unobtainable, but that should not preclude us from striving for perfection, when time, circumstance or desire allow.