Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re^2: inheritance: constructors

by Anonymous Monk
on Dec 01, 2012 at 02:50 UTC ( [id://1006562]=note: print w/replies, xml ) Need Help??


in reply to Re: inheritance: constructors
in thread inheritance: constructors

Please, I beg you, do not tell people they should use an else/unless construct. Ever. I wish this wasn't even possible. People need to think in the proper order.

Replies are listed 'Best First'.
Re^3: inheritance: constructors
by Athanasius (Archbishop) on Dec 01, 2012 at 03:33 UTC

      Sorry, I'm not buying. This is not ok? --

      if ( $value != $expected_value ) { $errorcount++; die new Exception msg => "argh!"; } else { # continue with the happy path }

      But this is ok? --

      if ( $value != $expected_value ) { $errorcount++; die new Exception msg => "argh!"; } # continue with the happy path

      no, no, no.

      I reckon we are the only monastery ever to have a dungeon stuffed with 16,000 zombies.

        Well, in

        if (...) { die ...; } else { # continue with the happy path }

        the provision of an else block is redundant, since it suggests (misleadingly) that the code can somehow die and yet still resume execution following the else — which it can’t.

        For this case, I would prefer:

        unless ($value == $expected_value) { $errorcount++; die new Exception msg => "argh!"; } # continue with the happy path

        which reads more naturally (to my ear). (Note that the original objection was not to unless, but to unless ... else.)

        Update: Nice use of the <abbr> tag, BTW — I’ve learnt something new, could come in handy.  :-)

        Athanasius <°(((><contra mundum

      You assume the order of the code blocks does not matter, too most ppl it does.

      Either: if ($i != $j) or: unless($i == $j)

      Chose one, these are the same. Your example changes much more than just removing a double negative.

Re^3: inheritance: constructors
by Anonymous Monk on Dec 01, 2012 at 02:52 UTC
    See? I can't even think "unless/else" properly. Ugh. Backwards thinking is why so many of us Perlmongers get made fun of by the other programmers. And why our successors curse our names when they have to maintain our code. Stop the madness.

Log In?
Username:
Password:

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

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

    No recent polls found