develooper Front page | perl.perl5.porters | Postings from July 2019

ideas for warnings (that might have already happened in the lastdecade)

Thread Next
From:
David Nicol
Date:
July 23, 2019 21:27
Subject:
ideas for warnings (that might have already happened in the lastdecade)
Message ID:
CAFwScO_=YqzjCHgSitMGHv-63g1AR_OarQzg0smy=+WyXaTH+A@mail.gmail.com
1: There should be a warning when a numeric comparator has as one of its
sides a constant string.

2:  There should be a warning when a reference is used in a boolean context.


Examples, based on what I saw today in the wild:

     if ($array_reference){
           if ($dispatch_flag == 'green'){
                 handle_green_case($array_reference)
           }elsif ($dispatch_flag == 'blue'){
                 handle_green_case($array_reference)
           }else {
                 neither_blue_nor_green($array_reference)
           }
     }else{
            warn "it's empty!"
     }

For extra extra points #1 could upgrade to a string comparator, but that
might be too much DWIM.



-- 
"Plant yourself like a tree beside the river of truth and tell the whole
world: No, you move."

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About