Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re^4: Burned by precedence rules (== true)

by gwadej (Chaplain)
on Dec 28, 2008 at 20:46 UTC ( #732926=note: print w/ replies, xml ) Need Help??


in reply to Re^3: Burned by precedence rules (== true)
in thread Burned by precedence rules

Even outlawing comparisons to the constants isn't enough.

sub is_tested { return FALSE; }

and then used as

if( is_tested() ) { print "is tested.\n"; }

and, by the way, FALSE is defined to be 2. This was the sort of thing that haunted me for days.

I was using those expressions to describe the problem not the usage.

G. Wade


Comment on Re^4: Burned by precedence rules (== true)
Select or Download Code
Replies are listed 'Best First'.
Re^5: Burned by precedence rules (fail() if "false";)
by tye (Cardinal) on Dec 28, 2008 at 21:06 UTC

    Wow, defining your FALSE constant to a value that isn't actually false is such an amazingly bad idea that I never even considered it. Yes, don't define Boolean constants that completely defy your language's concept of "true" or "false". Duh! :) Thanks for mentioning that.

    - tye        

      I have often said that I have learned as much from the really bad code that I have maintained as I have from the really good code I have maintained. (That applies to both my code and other people's code.)

      If a value of FALSE that is not false doesn't scare you enough, I won't tell you what I found FOUR defined as...<grin/>

      G. Wade

        I still have to say that my favorite maintenance horror is the block that had (including comments) the $language equivalent of

        $x = 1; $x = 1; # Just to be sure

        *shudder*

        --MidLifeXis

        No doubt it was originally defined as FOUR = 4, but then somebody was told to change it to 42 or π. This is why I tend to avoid setting constants like THREE = 3. I find it rather annoying to have constants with clear names that lie. After all, complex code is self-obfuscating; it doesn't need any help.


        Information about American English usage here and here. Floating point issues? Please read this before posting. — emc

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (12)
As of 2015-07-31 09:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (276 votes), past polls