in reply to Should 'use warnings' check for contradictions?

In your example, it's obvious that the loop condition can never be true. However, in general, determining whether a given expression is satisfiable (that is, can possibly be true) is an NP complete problem. There's no known efficient algorithm for it. You can put in more and more simple checks for more and more obvious cases, but how far down that path do you want to go?

It's also useful to be able to do something like this:

$DEBUG = 0; ... print "foo\n" if $DEBUG;
without having use warnings scream at you. So a condition that's always false is not always wrong.

Maybe you should choose variable names that don't look so similar to each other. For instance, $team1_score and $old_team1_score would be less likely to get confused than $team1_score and $team1_scorec.

Replies are listed 'Best First'.
Re: Should 'use warnings' check for contradictions?
by Abigail-II (Bishop) on Jun 10, 2002 at 13:03 UTC
    It's "only" NP complete if the clauses are known. But here the clauses are expressions, and can have side-effects (ties, threads, overload) so determining whether this would never be true quickly reduces to the halting problem.

    And no automaton that's powerful to run Perl on which the halting problem is decideable is known.

    Abigail