Re: Re: The One True Style of indentation:by pdcawley (Hermit)
|on Apr 17, 2002 at 08:23 UTC||Need Help??|
It's weird, I normally go with four spaces in personal code, but in my recent Perl6 'apocryphal' SchemeInterpreter I switched over to two spaces and I'm surprised by how much I like it.
Then again, this is code that I'll likely be using as the basis for an pod file discussing how it works and what's changed since Perl 6, so horizontal space is precious.
All that said, I'll use whatever the prevailing style is at whatever site I'm working on. If there is no prevailing style then I'll work to get one established and will argue for my choices, but once consensus is reached I go with that. The one thing I will not stand for is tabs used for anything but 'basic' indentation. For instance, consider the following (not good style, but it's just here to illustrate a point) code:
If tabs are used for indentation then the 'actual characters' used would be as follows. Take '>>>>' to equal one tab.
Using 'hard' tabs to do 'alignment' formatting is Bad And Wrong; it embeds your assumptions about tab width into the source file thus defeating the purpose of using tabs in the first place. Don't do it people.
I would be much more sanguine about tab indented code if people stuck to this rule, but unfortunately, they don't. Even more depressingly, the likes of emacs's otherwise wonderful cperl-mode doesn't make the distinction either. So for now, I argue for 'indents shall be a fixed number of spaces per level'. All things being equal, I choose four.
Yes, your assumptions are embedded in the source this way, but at least your careful formatting doesn't get fscked over when someone chooses a different tab width to view it with.