develooper Front page | perl.perl5.porters | Postings from August 2008

Re: print interpreted as function (was: Re: SURPRISE(?): return() VS other builtin()s)

Thread Previous | Thread Next
From:
Reini Urban
Date:
August 4, 2008 04:04
Subject:
Re: print interpreted as function (was: Re: SURPRISE(?): return() VS other builtin()s)
Message ID:
6910a60808040403j356e2e77jaabb44e5a13490e7@mail.gmail.com
2008/8/4 Abigail <abigail@abigail.be>:
> On Sun, Aug 03, 2008 at 03:41:01PM -0600, Tom Christiansen wrote:
>>
>>     4.  Are you surprised that the [CcD]_print functions elicit
>>         no "print interpreted as function" warning?
>
>
> No.
>
>
> The "print interpreted as function" is not only the most worthless
> warning in Perl; it not only generates an awful lot of false positives,
> it also misses out cases where it should have warn.
>
>
> For instance:
>
>
>  print(1)                       # No warning.
>  print (1)                      # Warning.
>  print (1)                      # No (!) warning.   (It's a tab, not a space)
>  print  (1)                     # No warning.
>
>
>  print (1)                      # Warning.
>  printf (1)                     # Warning.
>  sprintf (1)                    # No warning.
>  log (1)                        # No warning.
>  sort (1)                       # Warning.
>
>
>  print ($_)                     # Warning.
>  print ($))                     # No warning.
>
>
>  print (1) || die;              # No warning.
>  print (1) && die;              # Warns in 5.8.8; not in 5.10.
>  print (1) and die;             # No warning.
>  print (1) or die;              # No warning.
>  print (1) xor die;             # Warning.
>
>
>  print (1) for f ();            # Warns in 5.8.8; not in 5.10.
>  print (1) if f ();             # No warning.
>  print (1) unless f ();         # No warning.
>  print (1) while f ();          # No warning.
>
>
>  do {print (1); next} if f ();  # No warning.
>  if (f ()) {print (1)}          # No warning.
>  print ($_), next if f ();      # Warning.
>
>
> And now for the truly bizar:
>
>  print ("1")                    # Warning.
>  print ("1");                   # No warning.
>  print (")")                    # Warning.
>  print (")");                   # Warning.
>  print (");")                   # No warning.
>  print ("(")                    # Warning.
>  print ("(");                   # Warning.
>  print (");"), next if f ()     # No warning.
>  print ("(;"), next if f ()     # Warning.
>
> When I compile a perl intended for actual use, I first rip out the first
> if statement of S_checkcomma in toke.c.
>
> I once submitted a patch for that against the core, but that was rejected.
> People actually seem to be fond of this beast.

Ok, so let's just try it again.
But this time via perlbug to the tracker also, so there will be some
justification of the reject.

Maybe we can fix the other false warnings also.

I also had my problems with print before.
http://thread.gmane.org/gmane.comp.lang.perl.perl5.porters/60267
-- 
Reini Urban
http://phpwiki.org/ http://murbreak.at/

Thread Previous | 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