Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re^4: unless versus if ( ! ) inside a subroutine

by halley (Prior)
on Jan 16, 2008 at 14:02 UTC ( #662677=note: print w/replies, xml ) Need Help??


in reply to Re^3: unless versus if ( ! ) inside a subroutine
in thread unless versus if ( ! ) inside a subroutine

Conditionals are not always evaluated. The compiler can sometimes decide to phrase things differently.
U:\> perl -MO=Deparse -le "$x = 5; if ($x) { print $x }" $x = 5; if ($x) { print $x; }
U:\>perl -MO=Deparse -le "$x = 5; if (0) { print $x }" $x = 5; '???';
U:\>perl -MO=Deparse -le "$x = 5; if (1) { print $x }" $x = 5; print $x;;
U:\>perl -MO=Deparse -le "$x = 5; if (! 0) { print $x }" $x = 5; print $x;;

--
[ e d @ h a l l e y . c c ]

Replies are listed 'Best First'.
Re^5: unless versus if ( ! ) inside a subroutine
by almut (Canon) on Jan 16, 2008 at 15:11 UTC

    Sure, but in those cases, constants are being tested in the conditional, which allows the compiler to make optimisations. In the OP's example, though, $v is a regular (mutable) scalar variable, which could change its value at runtime (after the compiler has done its work)...

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://662677]
help
Chatterbox?
[erix]: I'm not sure. I suppose you could compare behavior via DBD::Pg with behaviour of the naked SQL
[erix]: I mean, SQL with PREPARE
[choroba]: hmm... ok, will try

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (13)
As of 2017-09-19 13:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    During the recent solar eclipse, I:









    Results (220 votes). Check out past polls.

    Notices?