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.


"In adjectives, with the addition of inflectional endings, a changeable long vowel (Qamets or Tsere) in an open, propretonic syllable will reduce to Vocal Shewa. This type of change occurs when the open, pretonic syllable of the masculine singular adjective becomes propretonic with the addition of inflectional endings."  — Pratico & Van Pelt, BBHG, p68

In reply to Re: A Question of style. by jonadab
in thread A Question of style. by GrandFather

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.