Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re^3: A matter of style: how to perform a simple action based on a simple condition?

by Your Mother (Archbishop)
on Sep 26, 2010 at 21:45 UTC ( [id://862127]=note: print w/replies, xml ) Need Help??


in reply to Re^2: A matter of style: how to perform a simple action based on a simple condition?
in thread A matter of style: how to perform a simple action based on a simple condition?

You sort of describe what I see as the main reason to prefer the postfix. “If it is too hot,” just for one example has a dozen, if not nearly infinite, possible remedies, as you note. Drink cold water, take sleeping pills to remain unconscious through it, buy a swamp cooler, shoot yourself to end your misery, fill the oceans with iron powder… The action matters far more than the condition. The condition initiates extra mental effort when it comes first. It creates a theoretical, if not actual, decision tree. You can race ahead to what you think the action should/will be.

It's also, as noted by many, noisier and generally multiline, to do if blocks which also increases apprehension impedance. Again, in my view. It's Perl, we can do what we wish. I think most of the above replies in favor of the block are more about justifying one's comfort zone, a valid thing to care about, versus actually considering what might be easier to write and read in the simple case (I would never advocate postfix for a logic tree or situations with several actions and conditions in the statement).

It's funny you mentioned native languages because the same thing occurred to me. I am curious if the SVO order of English—or even lazy idiomatic regionalisms of which I'm the victim—have any bearing in the perception of which is “easier.”

  • Comment on Re^3: A matter of style: how to perform a simple action based on a simple condition?
  • Download Code

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (7)
As of 2024-04-18 11:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found