Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re^2: Perl oddities

by dragonchild (Archbishop)
on Mar 01, 2005 at 16:34 UTC ( [id://435513]=note: print w/replies, xml ) Need Help??


in reply to Re: Perl oddities
in thread Perl oddities

Which is more important - do_something() or $condition? The important bit should be left-most in indentation. I have often found
if (really_long_and_boring_condition) do_something_useful()

to be much harder to read in C. Plus, people seem to feel that just cause you don't have braces means you don't have to follow proper indentation practices. (Not that braces always help, but it allows me to bounce on % in (g)vi(m).)

Personally, I prefer the following alternatives:

do_something_useful() if really_long_and_boring_condition; # Or ... really_long_and_boring_condition && do_something_useful();

Depending on which is more important to understanding the program's flow.

Being right, does not endow the right to be rude; politeness costs nothing.
Being unknowing, is not the same as being stupid.
Expressing a contrary opinion, whether to the individual or the group, is more often a sign of deeper thought than of cantankerous belligerence.
Do not mistake your goals as the only goals; your opinion as the only opinion; your confidence as correctness. Saying you know better is not the same as explaining you know better.

Replies are listed 'Best First'.
Re^3: Perl oddities
by DentArthurDent (Monk) on Mar 01, 2005 at 21:28 UTC
    I would argue that if the condition is "really long and boring", then it is *more* important to have braces and whitespace so it is easier to see where the actual action being taken is at a glance. The only one you mention that could work for me is:
    do_something_useful() if really_long_and_boring_condition;
    Unfortunately, that's at the expense of putting the cart before the horse IMHO. The action doesn't matter if the condition is not satisfied.
    ----
    My mission: To boldy split infinitives that have never been split before!
      When I see "die if (long && complicated condition)" I know that I can stop reading the condition, because it's an error check and therefore probably not interesting to me. Or, if it says "$name = $1 if /long and complicated regex/;" then I can skip over the regex because I know what it's doing.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (8)
As of 2024-04-16 18:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found