On Tue, Aug 07, 2001 at 03:00:52PM +0200, Bart Lateur wrote:
> BTW can anybody explain how the "magic" works? I mean: how comes that in
> 
>       use constant DEBUG => 0;
>       if(DEBUG) {
>             .... # things to do when debugging)
>       }
> 
> that the if-block is supposed to be stripped from the compiled program,
> as if DEBUG was replaced with a literal 0? Is the compiler so smart that
> it recognizes a sub that returns a constant? It'd almost have to be that
> way.

Yes.  A subroutine that has an empty prototype and that simply returns a
constant value is inlined by the compiler.

Ronald

Reply via email to