Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

Re: Ampersands and sub speed

by cees (Curate)
on Oct 14, 2005 at 21:19 UTC ( #500373=note: print w/replies, xml ) Need Help??

in reply to Ampersands and sub speed

Make sure you know what you are doing when adding & to the front of a function call. It can have unintended consequences if you do not understand the difference. Here is the relevant section from perlsub that briefly explains the difference:

       To call subroutines:

           NAME(LIST);    # & is optional with parentheses.
           NAME LIST;     # Parentheses optional if predeclared/imported.
           &NAME(LIST);   # Circumvent prototypes.
           &NAME;         # Makes current @_ visible to called subroutine.

Replies are listed 'Best First'.
Re^2: Ampersands and sub speed
by creamygoodness (Curate) on Oct 14, 2005 at 21:55 UTC
    Yes, you'd have to comment every place you use it -- because this is one of those subtleties you couldn't assume a maintenance programmer would grasp.
    Marvin Humphrey
    Rectangular Research ―
      why wouldn't you assume he'd know basic perl?
        We can't all be geniuses like you, Anonymous.

        Mainly because it's *not* basic Perl. It's a subtle effect that isn't obvious. If the OP included the ampersands without commenting, it would be reasonable for a maintainer to remove them, not knowing the effect they have on speed. And as you are fond of pointing out, not everyone who programs is a good programmer, right?

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://500373]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (1)
As of 2018-02-19 04:26 GMT
Find Nodes?
    Voting Booth?
    When it is dark outside I am happiest to see ...

    Results (258 votes). Check out past polls.