Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re^6: What esteemed monks think about changes necessary/desirable in Perl 7 outside of OO staff

by likbez (Sexton)
on Sep 27, 2020 at 22:37 UTC ( [id://11122274]=note: print w/replies, xml ) Need Help??


in reply to Re^5: 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

This node falls below the community's threshold of quality. You may see it by logging in.
  • Comment on Re^6: What esteemed monks think about changes necessary/desirable in Perl 7 outside of OO staff

Replies are listed 'Best First'.
Re^7: What esteemed monks think about changes necessary/desirable in Perl 7 outside of OO staff
by GrandFather (Saint) on Sep 27, 2020 at 22:59 UTC

    Judging by the code I see at PerlMonks and in the various CPAN source I have looked at, post-fix statements are pervasive among experienced Perl users. I think partly this is true because they break through the clutter of more conventional languages to make "simple things simple" and clear.

    It is somewhat the difference between writing short comprehensible sentences in prose and writing longer tortuous incomprehensible meandering sentences that are harder to parse and harder to understand. Perl encourages short comprehensible sentences.

    Optimising for fewest key strokes only makes sense transmitting to Pluto or beyond

      For me, the choice between:

      consequence() if condition(); # or condition() and consequence();

      And the choice between:

      consequence unless condition(); # or condition() or consequence();

      Is mostly a question of front-loading. What part of the statement seems the most important in its context? If we're just trying to avoid warnings about undef values, then adding if defined $foo to the end of a statement seems less obnoxious than putting the condition up front. But if we're going to do a lot of processing on $line, then my $line = <$fh> or return; is probably clearer than return unless my $line = <$fh>;.

      A reply falls below the community's threshold of quality. You may see it by logging in.
Re^7: What esteemed monks think about changes necessary/desirable in Perl 7 outside of OO staff
by dsheroh (Monsignor) on Sep 28, 2020 at 08:06 UTC
    Sorry, but I use postfix conditionals because they follow the recommendations you cited, not because I'm obsessed with saving keystrokes.

    You want to "write clearly" and "say what you mean"? Great! Postfix conditionals help you to do that, by mirroring the syntax of common English sentences, such as "I would understand the use of post-fix if construct [implied "if"] in a loop to specify exit condition.", instead of having to rewrite your plain-English thoughts to force the conditional to always be stated first.

    A reply falls below the community's threshold of quality. You may see it by logging in.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (4)
As of 2024-04-24 13:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found