Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re^5: Closure warning with Perl 5.14?

by JavaFan (Canon)
on May 19, 2011 at 09:45 UTC ( #905647=note: print w/replies, xml ) Need Help??


in reply to Re^4: Closure warning with Perl 5.14?
in thread Closure warning with Perl 5.14?

Yeah, it only warns on my $var if 0, not on my $var = EXPR if COND. I do not know why.

Replies are listed 'Best First'.
Re^6: Closure warning with Perl 5.14?
by ikegami (Pope) on May 19, 2011 at 09:55 UTC

    To allow stuff like the following?

    print(my $x = 1234) if COND;

    Which is to say, they probably didn't want to step on anything that has remote chance of being legit.

      But my $x if COND; doesn't warn either, unless COND is false. Not sure what print(my $x = 1234) if 0; would be good for. Note also that print(my $x = 1234) if COND; does not have a my $x = EXPR if COND subexpression, not even on a textual level.
Re^6: Closure warning with Perl 5.14?
by John M. Dlugosz (Monsignor) on May 19, 2011 at 13:41 UTC
    That was a hack for getting state variables. So it might be found in code that should use state instead, and won't work as expected in the new versions.
      Yeah, but what is the intention of all other code that uses:
      my $var if COND;
      ? Either the if COND is redundant, because it's always true, or it maybe false and you have the same issue. Also,
      my $var = 0 if 0;
      creates a "state" variable, yet there's no warning.

      Now, I'm usually not a fan of adding a warning for every little thing, but if there's a warning, it shouldn't be inconsistent on when it warns and when it doesn't.

        Oh well.

        I agree with your sentiment.

        We could speculate about some code path or another that the warning was added to. But in general, if it was added to some specific code path in the perl implementation, it was either (1)he was working in that part of the code and added the warning because he could, (2) that specific path is one that changed its behavior under that circumstance, or (3) adding it there as opposed to systematically was low-hanging fruit.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://905647]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (1)
As of 2021-12-06 06:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    R or B?



    Results (31 votes). Check out past polls.

    Notices?