Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re^3: if variants

by DrHyde (Prior)
on Oct 21, 2004 at 08:40 UTC ( #401086=note: print w/replies, xml ) Need Help??


in reply to Re^2: if variants
in thread if variants

Noooooo! != is fine. It's unless ... else that is hideously broken!

Replies are listed 'Best First'.
Re^4: if variants
by apotheon (Deacon) on Oct 21, 2004 at 08:46 UTC
    I can understand avoiding the != in an if statement, since using unless covers that functionality. I don't know why unless . . . else would be "bad", however. Explain?

    - apotheon
    CopyWrite Chad Perrin
      In English, saying "if this, do that, else do the other" makes sense and is easy for a person to parse. However "unless this, do that, else do the other" is much harder to parse because the "else" clause is a double negative (or even a triple negative if you have "unless not this"). Same applies to perl.

      While you could, perhaps, argue that "if not this, do that, else do the other" is also a double negative, it's still easy to parse because it's familiar. We see it in every programming language ever.

        In short, then, it's a readability issue. Got it. Thanks.

        I think my facility for formal and symbolic logic systems probably makes it more difficult for me than for most people to recognize when some complex representation of a logical expression is difficult to parse by eye.

        - apotheon
        CopyWrite Chad Perrin

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://401086]
help
Chatterbox?
[stonecolddevin]: damn where's a working cblast? looks like several of them are out of commission
[erix]: Tanktalus home node has one
[stonecolddevin]: erix thanks mate
[stonecolddevin]: also lol @ "I stomped a crap"
[stonecolddevin]: Disciplus i was just amazed he's returned after the thorough stomp that BrowserUk and several other monks gave him for spreading crap info
[stonecolddevin]: i will admit i find the responses to his threads incredibly entertaining
[stonecolddevin]: erix what is this wizardy? there's no sound for me :-(
[stevieb]: he comes and goes every few years.

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (5)
As of 2017-06-22 20:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How many monitors do you use while coding?















    Results (529 votes). Check out past polls.