Skip Menu |

This queue is for tickets about the Method-Signatures CPAN distribution.

Report information
The Basics
Id: 93334
Status: resolved
Priority: 0/
Queue: Method-Signatures

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

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



Subject: Wishlist for Perl 5.20 signature compatibility: allow bare sigils
For example: method foo ($, $y) { ... } This should be roughly equivalent to: sub foo { my $self = shift; my $y = $_[1]; } Note that $_[0] still exists in the @_ array but hasn't been assigned to any lexical. Bare sigils `@` and `%` should be allowed as slurpies. This is essentially the same as a yada-yada, but in the case of `%` will die if the remaining argument list is not even-sized. The easiest way to implement this in my experience is to interpret a bare sigil `$` as being equivalent to `$tmp`, and otherwise handle it the same as any other parameter. However, when you inline the parameter handling code into the sub, wrap it in {...} so that `$tmp` immediately goes out of scope. That way, you can still handle things like type constraint checks, defaults, etc on the variable easily.
Show quoted text
> For example: > > method foo ($, $y) { ... } > > This should be roughly equivalent to: > > sub foo { > my $self = shift; > my $y = $_[1]; > } > : > :
I'm inclined to add this. schwern, do you have an opinion? tobyink, does this syntax come from any place in particular? Just curious.
Perl 6 supports this syntax, and is I believe where the syntax originated. https://github.com/perl6/roast/blob/master/S06-signature/positional.t MooseX::Method::Signatures also supports it. https://metacpan.org/pod/MooseX::Method::Signatures#Placeholders
Subject: Re: [rt.cpan.org #93334] Wishlist for Perl 5.20 signature compatibility: allow bare sigils
Date: Thu, 27 Feb 2014 09:42:31 -0800
To: bug-Method-Signatures [...] rt.cpan.org
From: Michael G Schwern <schwern [...] pobox.com>
On 2/26/14, 8:23 PM, Buddy Burden via RT wrote: Show quoted text
> I'm inclined to add this. schwern, do you have an opinion?
IMRTEOTO* I don't see any harm. * In My Reading This Email Over Tea Opinion, which is to say I haven't given it a lot of thought.
Okay dokey; we're in concensus on this one. I've set up [GitHub #100](https://github.com/schwern/method-signatures/issues/100) to track this issue.
This feature is added in 20160516.2032_001. I will close the ticket once that is promoted to a full release.
Full release it out. Resolving.