Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change

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.

Replies are listed 'Best First'.
Re^3: inheritance: constructors
by Athanasius (Chancellor) 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]
[Discipulus]: Eily tongue twister or votes? ;=)
[Eily]: Discipulus turn me into a Bishop
Discipulus abracadabra.. Eily tranformed into a.. shop for bisexual peoples..
[LanX]: Eily don't be sad ... you are the Bishop of our hearts.
[marto]: 1nickt, I just said that in a Sean Connery accent
[LanX]: Discipulus++ # Bi-Shop
[Eily]: is the Bishop of hearts higher or lower ranked than the Jack?
[ambrus]: Higher.
[Eily]: Discipulus what's the merchandise? Other bi-people?
[1nickt]: marto would like to hear that. Of course he speaks very deliberately and dramatically, allowing pauses between words, so if anybody could pull it off it would be him, or someone impersonating him ...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (13)
As of 2017-09-26 12:07 GMT
Find Nodes?
    Voting Booth?
    During the recent solar eclipse, I:

    Results (294 votes). Check out past polls.