in reply to Re^2: coderefs and (&) prototypes
in thread coderefs and (&) prototypes
the extra \& noise isn't going to prevent it from blowing up at run-time
The whole point of parameter validation is to blow up. Why would you want to prevent it?
Without the "extra noise", it wouldn't blow up. That's the problem.
sub f0 { my ($cb) = @_; '...' } sub f1(&) { my ($cb) = @_; '...' } f0(\&abc); # OK No error f0(\&{ maybe_coderef() }); # OK Error caught at run-time (if any) f0("abc"); # XX Error uncaught f0(maybe_coderef()); # XX Error uncaught (if any) f1(\&abc); # OK No error f1(\&{ maybe_coderef() }); # OK Error caught at run-time (if any) f1("abc"); # OK Error caught at compile-time f1(maybe_coderef()); # OK Error caught at compile-time (if any)
Update: Added example
|
|---|