in reply to style quest
The recommendation to use space around "complex" subscripts is intended to enhace readability. It's easy for the eye to scan return $foo[$i]; but it's harder to pick out what's going on with something like return $foo[rand(scalar @foo)]; without adding a bit of whitespace. Many find return $foo[ rand(scalar @foo) ]; to be more readable. The added whitespace makes it easier to visually scan the subscript.
Vertical whitespace is a related issue. Historically, vertical whitespace was once quite precious: you only got 24 lines of it on most displays. Consensus says to use enough to make things readable, but not too much. The "cuddled else" form (so-called because the else is cuddled between two braces) use one less line than the uncuddled form. Compare
withif ( $foo ) { bar(); } else { baz(); }
The cuddled else form uses one less line without (arguably) reducing readability. It's a style issue on which not all agree.if ( $foo ) { bar(); } else { baz(); }
One of the more important aspects of style is consistency. Consider what the Perl style guide has to say, and test it to see if it works for you. Then pick a practice and use it consistently. Readers can adjust to different styles, but inconsistency starts raising red flags.
|
|---|