What argument checking?
sub f { my ($arg1,$arg2,$arg3) = @_; .... uses arg1, arg2 arg3 .... } f(); # Works. ($arg1, $arg2 and $arg3 are undef.) f(1,2,3,4); # Works. ('4' is ignored.)
Maybe you're thinking of prototypes? & causes the prototype to be ignored. Use of & is discouraged for this reason. Then again, most prototypes are discouraged as well (for other reasons).
Aside from ignoring prototypes, (&f) means something different than f():
sub f { my ($arg1) = @_; print(defined($arg1) ? $arg1 : '[undef]', "\n"); } sub t1 { print("t1: "); f(); } sub t2 { print("t2: "); &f; } t1('moo'); # t1: [undef] t2('moo'); # t2: moo
When function f is called using &f (with no arguments), a new @_ isn't created; it shares the @_ of its caller.
Looking at it from the other direction,
f(...);
is equivalent to
do { local @_ = (...); &f };
(when no prototypes are involved).
Update: Added talk of prototypes.
In reply to Re: calling f(arg1,arg2,arg3) better than &f
by ikegami
in thread calling f(arg1,arg2,arg3) better than &f
by edwardt_tril
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |