Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: No Hard Tabs in Code

by MidLifeXis (Prior)
on Jul 01, 2010 at 13:12 UTC ( #847507=note: print w/ replies, xml ) Need Help??


in reply to No Hard Tabs in Code

There was a discussion in the CB the other day about this. The nearest concession I can make (I am a spaces person) is tabs at the beginning of the line to indent, and spaces to align after that.

My editor manages the alignment for many types of indent / align, and C-M-\ reindents a region in the current indentation configuration. Backspace is not needed since tab realigns the current line as necessary.

Set rules, let the tools follow them. Anything else is TooMuchWork(tm) ;-)

--MidLifeXis


Comment on Re: No Hard Tabs in Code
Re^2: No Hard Tabs in Code
by fullermd (Curate) on Jul 02, 2010 at 20:34 UTC
    The nearest concession I can make (I am a spaces person) is tabs at the beginning of the line to indent, and spaces to align after that.

    That isn't a concesssion; it's the only valid way.

    I'm very much a tab person. Tabs are for indenting. They're not for aligning. Indenting is a logical concept, aligning is a visual one. It doesn't matter what size your tabs are set to; N tabs at the start of a line are always the same size as N tabs at the start of the line, always smaller than N+1 tabs, and always larger than N-1 tabs. That's perfect for indenting.

    However, a tab is not the same size as any number of spaces, nor are tabs following something other than BOL or tab the same size as any other tabs. That's alignment; tabs aren't for that.

    (____ is a single tab. So is ----, for clarity.)

    ____if(x ____ && y) ____{ ____----print "some foo" ____---- . "some bar"; ____} ____struct foo ____{ ____----int xyz; ____----unsigned char *abc; ____}

    IMO, it's pretty obvious what's indentation and what's alignment. Using tabs for the latter, outside of very special cases, is a mortal sin.

      Specifically, using tabs to align defeats the purpose of using tabs. (You are no longer free to choose your preferred indentation distance)

      Using spaces to indent, on the other hand, is a bit like having a fixed width web page. It is the wrong size for the majority of people, but it is at least consistent.


      In a perfect world, everything would show tabs at your preferred width, people would not use tabs for alignment and everybody would see code in their own preferred style independent of the original coder. Indentation would be distinct from code. There could even be a way to indicate which curly brackets qualify for an optional linebreak plus indentation.

      But display/edit programs don't show properly, and people don't write properly. This is why we can't have nice things :P


      PS: Actually, this seems a lot like web pages... using tabs to align is as bad as using a 20% width object to align text. Just Doesn't Work.

      Using spaces everywhere is like perldoc's fixed width syndrome. Running a script to convert the indentation (bigger or smaller) is like having to write and apply a style override for the website. Makes it less convenient and uglier than it should be, but also more useful than the original state.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://847507]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (7)
As of 2014-07-30 02:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (229 votes), past polls