Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: Re: inlined DEBUG constant versus $DEBUG

by stefp (Vicar)
on Sep 19, 2001 at 18:23 UTC ( [id://113349]=note: print w/replies, xml ) Need Help??


in reply to Re: inlined DEBUG constant versus $DEBUG
in thread inlined DEBUG constant versus $DEBUG

I never claimed significant speed improvement. What I had in mind is debugging thru the perl debugger. In that case the print statement becomes noise. I don't want anything to print, I even don't want to bother to go thru the statement that contains the print. Oddly, with use constant DEBUG => 0 I indeed step thru the statement that contains the print:  print "whatever\n" if DEBUG.
Worse I also step thru one line of constant.pm!

With sub DEBUG() { 0 } I still step thru the statement that contains the print. When debugging one goes from one nextstate opcode to the next. We see that consecutive nextstate statements are not fusionned as I expected them to be:

Both oneliners give me the same tree: perl -e ' sub DEBUG() { 0 } ; use O qw( Concise -exec); print "toto" if DEBUG; print "toto" if DEBUG'

perl -e ' use constant DEBUG =>0; use O qw( Concise -exec); print "tot +o" if DEBUG; print "toto" if DEBUG' 1 <0> enter 2 <;> nextstate(main 1 -e:1) v 3 <;> nextstate(main 1 -e:1) v 4 <@> leave[t1] vKP/REFC

I don't understand how I get thru one line of constant.pm when debugging using constants!!!

I tested using perl 5.6.1

-- stefp

Replies are listed 'Best First'.
Re: Re: Re: inlined DEBUG constant versus $DEBUG
by derby (Abbot) on Sep 19, 2001 at 19:14 UTC
    stefp,

    That's why I tend to favor 'n' over 's'. However, when I debug code that contains

    sub DEBUG () { 0 }
    I still step through the DEBUG subroutine. Which is what I would expect while debugging. Try:

    perl -de 'use constant DEBUG =>0; use O qw( Concise -exec); print "toto" if DEBUG; print "toto" if DEBUG'

    perl -de 'sub DEBUG() { 0 }; use O qw( Concise -exec); print "toto" if DEBUG; print "toto" if DEBUG'

    -derby

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (3)
As of 2025-06-22 18:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.