in reply to Re^3: My coding guidelines
in thread My coding guidelines
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.
This could be a problem, but it shouldn't be difficult to eliminate it. In order to do so, even if you use a mix of spaces and tabs to indent (or rather to align things vertically) just always use tabs to indent (that is, to align vertically the left margin of the lines), and reserve the use of spaces to align vertically only the things past the left margin (in the middle of a line, so to say) such as the => symbol in a hash.
In other words, never use spaces to align the left margin and reserve their use only to align the things inside a line.
Here is an example:
I've personally used (and spread) this convention for years (mainly with languages different from Perl though) and never had a single problem or complaint.
my %a_hash = (
<TAB> very_very_long_key => 1,
<TAB> k2 <SPACES> => 2,
<TAB> another_k <SPACES> => 3
The only problem I can see happens if you want to use a fancier alignment like this:
but frankly I would avoid it (though some people seem to like it).
my %a_hash = (
very_very_long_key => 1,
k2 => 2,
another_k => 3
IMO forcing people to use your indentation is minimal issue
This is true as long as everyone religiously adopt the same, sensible number of spaces (4 could be OK, but not necessarily, see later), but I've seen so many times people who love to indent with just 2 spaces or even with a single space.
As for the 4-spaces convention, not everyone agree: for example both the Linux kernel and the Gnome coders recommend to use 8-spaces (tabs) for indentation.
Thanks to their portability, tabs are IMO the only way to to settle this controversy and make everyone happy.