Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?

Re^2: inheritance: constructors

by Anonymous Monk
on Dec 01, 2012 at 02:50 UTC ( #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.

Comment on Re^2: inheritance: constructors
Replies are listed 'Best First'.
Re^3: inheritance: constructors
by Athanasius (Canon) 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?

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

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (13)
As of 2016-02-09 16:29 GMT
Find Nodes?
    Voting Booth?

    How many photographs, souvenirs, artworks, trophies or other decorative objects are displayed in your home?

    Results (320 votes), past polls