in reply to Re: Re: Re: subroutine constants
in thread subroutine constants

Ah, but: sub BUFFER() { 2048 } is also a compile-time construct.

The () means that uses of BUFFER can be optimized away so that the code gets compiled as if you said 2048 directly. Without the (), each time an instance of BUFFER is encountered at run time, a Perl subroutine call has to be executed.

I doubt you'd be able to notice a speed difference between the two without trying really hard. But it also makes the compiled code a little smaller and declares your intention to not change this definition at run time.

        - tye (but my friends call me "Tye")

Replies are listed 'Best First'.
Re: (tye)Re: subroutine constants
by suaveant (Parson) on Sep 21, 2001 at 01:04 UTC
    Ooooh... ahhhh... teach me oh great one ;)

    I suppose if you had a few thousand constants you would notice it... :)

                    - Ant
                    - Some of my best work - Fish Dinner