Subject: | Wishlist for Perl 5.20 signature compatibility: allow sub attributes to precede the signature |
Function::Parameters, along with most other similar modules on CPAN, has used the following syntax to define a sub with both a signature and an attribute:
method foo ($bar) :Baz { ... }
Meanwhile Perl 5.20 seems to be taking the more questionable approach of:
sub foo :Baz ($self, $bar) { ... }
It ought to be fairly simple for Function::Parameters to allow attributes to be provided in *both* locations (i.e. both before and after the signature).
Note that when attributes are provided *before* the signature, the whitespace separating them from the signature is significant. Consider the following two declarations:
sub foo :Baz ($self, $bar) { ... }
sub foo :Baz($self, $bar) { ... }
The former declaration has an attribute of ":Baz" followed by a signature. The latter has an attribute of ":Baz($self, $bar)" but no signature.
The significance of whitespace here has been confirmed to be intentional by Zefram and others on #p5p.