Anyway, looking at some of the source code I noticed a very subtle bug. The program works as follows:
Obviously this code contains an error. In the second 'clause' of the 'if' statement, I'm comparing a variable to itself. I meant to write $team2_scorec instead.if ( ($team1_score ne $team1_scorec) or ($team2_score ne $team2_score) + ) { $changed_matches{$team1} = $changed_matches{$team2} = "$team1 vs $team2 ($team1_scorec - $team2_scorec)"; }
So surely the expression $team2_score ne $team2_score is a contradiction--it will never evaluate as true.
So, wouldn't it be good if Perl could warn about this? It would have saved me a lot of trouble.
I suppose it might be possible that a thread could access the variable and change it, but I would imagine that the ne operator would be implemented in a sort of 'atomic' fashion.
I'd be interested to hear your views on this. Would it be difficult to create a pragma to spot contradictions and tautologies as well?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Should 'use warnings' check for contradictions?
by chromatic (Archbishop) on Jun 09, 2002 at 16:43 UTC | |
|
Re: Should 'use warnings' check for contradictions?
by Juerd (Abbot) on Jun 09, 2002 at 17:00 UTC | |
|
Re: Should 'use warnings' check for contradictions?
by no_slogan (Deacon) on Jun 09, 2002 at 16:34 UTC | |
by Abigail-II (Bishop) on Jun 10, 2002 at 13:03 UTC | |
|
Re: Should 'use warnings' check for contradictions?
by clintp (Curate) on Jun 09, 2002 at 15:05 UTC | |
|
Re: Should 'use warnings' check for contradictions?
by BrotherAde (Pilgrim) on Jun 12, 2002 at 22:02 UTC |