The real question is why doesn't it accept arbitrary expressions that return a code ref. And the answer is that there's no way to guarantee that the expression will return a code ref.and then
\&cb is guaranteed to return a code ref, so it's allowed for (&). By extension, this includes \&{ EXPR }.
I don't understand these two together. There's no way to guarantee that EXPR in \&{ EXPR } will evaluate to a code-ref either, and, if it doesn't, the extra \& noise isn't going to prevent it from blowing up at run-time—so why put the programmer through that extra syntactic hassle, if it doesn't buy him or her any extra safety?
In reply to Re^2: coderefs and (&) prototypes
by JadeNB
in thread coderefs and (&) prototypes
by LanX
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |