Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re^15: What esteemed monks think about changes necessary/desirable in Perl 7 outside of OO staff (Use block if not postfix if References)

by eyepopslikeamosquito (Archbishop)
on Oct 11, 2020 at 23:55 UTC ( [id://11122718]=note: print w/replies, xml ) Need Help??


in reply to Re^14: What esteemed monks think about changes necessary/desirable in Perl 7 outside of OO staff
in thread What esteemed monks think about changes necessary/desirable in Perl 7 outside of OO staff

For completeness, note that Perl Best Practices, chapter 6 (Control Structures), "Use block if, not postfix if" argues that postfix-if does not scale as well as block-if, and is harder to comprehend (except in simple cases). I agree, especially with the scaling argument. Always using block-if has made code reviews more enjoyable for me over many years because there are fewer changed lines of code to review whenever you just add an extra statement to a block-if (compared to more violently restructuring the code from postfix-if to block-if).

In chapter 4 (Values and Expressions), "Don't mix high- and low-precedence booleans", Conway recommends using the low precedence and and or operators for flow of control, for example:

open(my $fh, '<', $file) or die "error opening '$file': $!";
while reserving && and || for logical expressions (not flow of control) for example:
if ($x > 5 && $y < 10) ...
Following this simple rule over the years has made the code easier to understand at a glance, at least for me.

  • Comment on Re^15: What esteemed monks think about changes necessary/desirable in Perl 7 outside of OO staff (Use block if not postfix if References)
  • Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11122718]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (5)
As of 2024-04-18 23:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found