http://qs1969.pair.com?node_id=580104


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

I prefer this, as I thought I'd already stated. :-)

my($foo) = blah($yadda); unless( $foo ) { $foo = barf->new(); } unless( $foo ) { $foo = gazonkly(); } if ( $foo < $boo ) { return ERROR_CODE; }

When reading this code, if I determine that $foo was set to a non-zero value greater than $boo by function blah(), I only need to read the first half of each of the subsequent lines to know they don't impact the scenario I'm considering.

When they're written backwards to the underlying logic, I can't do that. I have to read all of each line, and then forget what I've read if it doesn't apply. That's why I don't consider the idiom any clearer when written backwards. I have to wonder: why did you think reversing tradition was a good idea in this (specific) case?

Replies are listed 'Best First'.
Re^7: If I was forced to program in another language, the Perl language feature I would miss most would be:
by BerntB (Deacon) on Oct 24, 2006 at 13:21 UTC
    I have to wonder: why did you think reversing tradition was a good idea in this (specific) case?
    Again, because I have made a couple of idioms out of this, so there is always this way of filling in a parameter and handle error returns.

    This might be a basic brain difference -- some people read code from left-to-right religiously on a line. I guess you are one of those. Others of us don't.

    I don't know why that isn't so important for me, at least in this case. Since I align the right side test, I can see directly from the shape of the code where the initing/error handling is done. If I can handle natural languages with irregular verbs, I can handle this idiom.

    It took me quite a while before I ever wrote with postfix if, because I was "C-damaged". (I'm not claiming you're too C/java-damaged -- I just think it is different wiring of brain visual centers, or something.)

    (Hmm.. maybe I should change habit to make it easier for you people that hate that..? :-( )