Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re^4: My coding guidelines

by Aristotle (Chancellor)
on Nov 27, 2002 at 18:22 UTC ( #216144=note: print w/ replies, xml ) Need Help??


in reply to Re: My coding guidelines
in thread My coding guidelines

The reason I like tabs is because of metainformation - one tab = one level of indentation. I use tabs only at the beginning of the line and only to indent. If I need to vertically align, say, the fat commas in a hash assignment, I use spaces; even if for some reason I wanted to right-align said hash keys I would indent them with tabs then add spaces in front of the keys.

That way, so long as you don't vertically align things on lines across different levels of indentation (and if you want to do that, something is probably wrong), everything will always line up regardless of the reader's tabwidth setting.

(See Re: download progress with gtk for an example of how I indent.)

Makeshifts last the longest.


Comment on Re^4: My coding guidelines
Re: My coding guidelines
by Abigail-II (Bishop) on Nov 28, 2002 at 10:11 UTC
    But if you use spaces instead of tabs, indentation will also align. And you don't run the risk lines will be pushed over the 80 char limit if someone uses different tab settings.

    Abigail

      But if you use spaces instead of tabs, indentation will also align. And you don't run the risk lines will be pushed over the 80 char limit if someone uses different tab settings.
      But using spaces you are forcing the others to use for indentation the same number of spaces you've chosen, while they may prefer to use different settings.

      Think for example of a visually impaired person (or simply a tired night coder) who wants 8-spaces indentation, who deliberately sets her tabs that way, to obtain what she wants regardless of the indentation habits of her colleagues (and still preserving their freedom to nest as deep as they prefer).

      By using spaces for indentation, as you suggest, your are forcing her to use your own indentation settings (which could be even a single space for that matter), which is not kind at all. Furthermore, any decent editor permit you to (automatically) convert tabs to spaces (the amount of them you prefer), while the opposite is not (always) true.

      In a word, tabs are portable, while spaces aren't (so tabs are not evil ;-)

      Ciao,
      Emanuele.

        In a word, tabs are portable, while spaces aren't (so tabs are not evil ;-)

        I would say you are right, except for one thing. You will virtually always find situations where you can't indent properly with just tabs alone. Which means that if you work with tabs set at different size the code turns becomes very difficult to deal with. Spaces alone are much easier to work with. And they avoid the perenial argument about how long a tab will be. IMO forcing people to use your indentation is minimal issue, as the tendency seems to be that if you work on someone elses code, or on shared code, that you should follow the indentation style for the code itself, not your own preferences.

        ---
        $world=~s/war/peace/g

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (5)
As of 2014-09-18 02:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (105 votes), past polls