On Mon, Sep 04, 2000 at 09:52:19PM -0000, Perl6 RFC Librarian wrote:
> Perl winges if you compare an undefined value.  This is silly and one often
> has to test for the undefined case (and the empty case for == and !=), then
> the equality that the programs logic calls for.  If you leave warnings off
> perl does the right thing anyway.

Removing undefined value warnings from comparisons will make subtle
bugs extremely difficult to find.  Consider the following:

    use constant ERROR_FLAG => 1;

    ...code and stuff...

    has_error($flag);

    sub has_error {
        my $flag = shift;
        if( $flag == ERROR_FLAG ) {
            warn "AHH!  An error!";
        }
    }

If the program fails to properly set $flag, has_error() will quietly
fail.  This simple example constitutes an enormous set of programming
mistakes which are difficult enough to find as it is, but will be
compounded by the lack of any warning.

Using an uninitialized value/undefined value is a mistake 9 of 10
times.  If you've hit a case in which you want to compare against an
undefined value, "no warnings 'uninitialized'" is available.  You may
wish to propose a tighter subcase of this warning which encompases the
conditionals you described.

Ignoring warnings should be a conscious decision on the part of the
programmer, NOT a fiat by the language designer.


-- 

Michael G Schwern      http://www.pobox.com/~schwern/      [EMAIL PROTECTED]
Just Another Stupid Consultant                      Perl6 Kwalitee Ashuranse
Maybe they hooked you up with one of those ass-making magazines.
        -- brian d. foy as misheard by Michael G Schwern

Reply via email to