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

Re: If I was forced to program in another language, the Perl language feature I would miss most would be:

by BerntB (Deacon)
on Oct 17, 2006 at 18:28 UTC ( [id://578870]=note: print w/replies, xml ) Need Help??


in reply to If I was forced to program in another language, the Perl language feature I would miss most would be:

The thing I'd miss most would be postfix if. I do this a lot:
... return ERR_CONST_CODE1 if <error test1>; return ERR_CONST_CODE2 if <error test2>; ...
It looks so nice and is so readable.

Replies are listed 'Best First'.
Re^2: If I was forced to program in another language, the Perl language feature I would miss most would be:
by Anonymous Monk on Oct 17, 2006 at 20:37 UTC
    It looks so nice and is so readable.

    I disagree. It doesn't follow the code flow.

    When debugging or analysing the code, you don't find out until the very end of the line whether or not you actually needed to read the line. By that point, you've had to read it anyway.

    I find it quite jarring to read, for all but the simplest of expressions. Then again, I find the same thing for lists of English instructions, too.

    unlink($file) && crack_password() && sacrifice_firstborn( $child ) && +take_over_world( $mwahahahaha ) if ( $ignore_all_that_just_kidding);
      I mainly use it for returning error cases (as I showed) and for things like alternative initiation of variables:
      ... my($foo) = blah($yadda); $foo = barf->new() unless $foo; $foo = gazonkly() unless $foo; return ERROR_CODE if $foo < $boo; ...
      I am not exactly known for aesthetical good taste, but I like it. If you have a clearer way of writing things like that, please tell me.
        Is this what Perl's or-equals or defined-or-equals operators are for?
        $foo ||= barf->new(); $foo ||= gazonkly();
        or to only test undef:
        $foo //= barf->new(); $foo //= gazonkly();
        When code is written as

        if (<expr>) { statement }

        instead of

        statement if <expr>;
        you can mentally decipher the code in the order of control flow. That's what I prefer.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (6)
As of 2024-03-29 01:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found