Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"

Re: Using & in function calls

by Sidhekin (Priest)
on Sep 28, 2007 at 23:01 UTC ( #641636=note: print w/replies, xml ) Need Help??

in reply to Using & in function calls

&snafu, as you have it, without parentheses, is actually even more magical: It passes the current @_ toshares the current @_ with the function called. Which you rarely, if ever, want.

(Updated: Yeah, that's better. lodin++.)

The &snafu(@args), &snafu(), and &snafu forms are useful in very rare situations, and the & is a nice flag for just those instances: When I see it in my code, I know I'm doing something strange. Which is also useful.

So yeah, not just aesthetics. Compelling enough? You make the call. But my recommendation for &-form calls is as for prototypes:

Don't use it if you don't mean it!

print "Just another Perl ${\(trickster and hacker)},"
The Sidhekin proves Sidhe did it!

Replies are listed 'Best First'.
Re^2: Using & in function calls (&foo != foo(@_))
by lodin (Hermit) on Sep 29, 2007 at 16:08 UTC

    It passes the current @_ to the function called.

    This is probably just a matter of wording, but I'd say it's sharing @_. &foo and foo(@_) are not equivalent. An example:

    sub foo1 { &bar; print "@_\n"; } sub foo2 { bar(@_); print "@_\n"; } sub bar { shift } foo1(1, 2, 3); foo2(1, 2, 3); __END__ 2 3 1 2 3


Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://641636]
[Discipulus]: yes, unfortunately.
[Corion]: Discipulus: you can "easily" trap shutdown/logoff in a Win32::GUI application by capturing and responding to the appropriate message
[LanX]: choroba wants to scale further? :)
[Discipulus]: I read an article about how much the female condition has got worst in the eastern europe after the fall of social policies
LanX has a friend in Berlin who switched to go(lang) and just got a kid ...
[marto]: good morning all
[Corion]: Hi marto ;)
[Discipulus]: Corion ah! you opened a new search path! thanks
[choroba]: LanX No, but they grow and want more!
LanX was conditioned by a female

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (13)
As of 2017-01-17 09:45 GMT
Find Nodes?
    Voting Booth?
    Do you watch meteor showers?

    Results (154 votes). Check out past polls.