Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: Conditional Compiling

by Arunbear (Prior)
on Nov 17, 2004 at 21:30 UTC ( [id://408597]=note: print w/replies, xml ) Need Help??


in reply to Conditional Compiling

Since LOGGING is a flag rather than a true constant, why not treat it the same way as you have treated $LOG_FILE_NAME i.e. as a (read only) scalar:
*{"${caller_pkg}::LOGGING"} = \$lexical_log;

Replies are listed 'Best First'.
Re^2: Conditional Compiling
by ikegami (Patriarch) on Nov 17, 2004 at 21:52 UTC
    Because log(...) if LOGGING compiles to nothing given sub LOGGING () { 0 } (refer to the first parse tree in the OP), whereas, log(...) if $LOGGING would cause $LOGGING to be evaluated at runtime everytime the line is encountered. While that's probably a negligable cost, it doesn't meet the goal I set at the top of my post. That goal can be alternatively stated as "I want the if to execute at compile time instead of at run-time (while keeping the code simple)."
      Ok, I get it now. It's quite a cool technique which is also used by Carp::Assert (for disabling assertions).

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (3)
As of 2024-04-25 19:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found