in reply to Re: A Question of style.
in thread A Question of style.
It doesn't matter what style of indentation you use. As long as you use it consistently.
If by "consistently" you mean "always the same way", then I actually disagree with this, at least to some extent. It is my considered opinion that good indentation style takes into consideration the semantics of the code being indented. Sometimes I put up to three "statements" (things between semi-colons) on the same line, if what they are doing is sufficiently related that it enhances, rather than impedes clarity, and indeed, that can make a block rather compact...
if (condition) { $foo=0; $bar++; }
But I certainly wouldn't recommend doing *all* conditional blocks that way. Also, sometimes I put something after a closing brace, on the same line, but only if what it's doing is related to the closing of the block, as in...
open FOO, '<', $filename; while (<FOO>) { chomp; my ($bar, $baz, $quux) = $_ =~ /someregex/; push @quux, [$foo, $baz, $quux] if $quux; } close FOO;
But again, I certainly wouldn't recommend always putting code on the same line after the closing brace. If it weren't logically related to the closing of the block, that could get very confusing. If I had to distill this to a general principle, it would be, take the code's semantics into consideration when deciding how much whitespace to use and where to use it.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: A Question of style.
by Nkuvu (Priest) on Jun 07, 2005 at 16:24 UTC |