Skip Menu |

This queue is for tickets about the Function-Parameters CPAN distribution.

Report information
The Basics
Id: 93339
Status: rejected
Priority: 0/
Queue: Function-Parameters

People
Owner: Nobody in particular
Requestors: perl [...] toby.ink
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: (no value)
Fixed in: (no value)



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.
On Tue Feb 25 07:14:04 2014, TOBYINK wrote: Show quoted text
> 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).
I don't like that syntax at all. I think putting anything between the function name and the parameter list is a mistake (it's supposed to mirror calling syntax). I don't even like writing 'sub foo ($bar)' (with the space in there). I'm going to reject this ticket until someone can give me a good reason why this attribute-before-parameters syntax should be valid. (Other point of reference: The perl core itself also uses GCC attributes like void foo(int) __attribute__((noreturn)); not void foo __attribute__((noreturn)) (int); (I don't even know if gcc would accept it).)
On 2014-10-12T15:59:37+01:00, MAUKE wrote: Show quoted text
> I don't like that syntax at all.
Personally it makes me vomit a little in my mouth. But I think it's worthwhile to support for forwards-compatibility with Perl native signatures, even if you additionally support (and encourage) attributes *after* the signature.