develooper Front page | perl.perl5.porters | Postings from October 2012

Re: sub signatures - too few arguments

Thread Previous | Thread Next
From:
Peter Martini
Date:
October 27, 2012 16:23
Subject:
Re: sub signatures - too few arguments
Message ID:
CAFyW6MQAAC9SWh=-C2RUAsJ9toha_FzBgdomqaGj+PzfsCKbdQ@mail.gmail.com
On Sat, Oct 27, 2012 at 7:14 PM, Eirik Berg Hanssen <
Eirik-Berg.Hanssen@allverden.no> wrote:

> On Sun, Oct 28, 2012 at 12:35 AM, Peter Martini <petercmartini@gmail.com>wrote:
>
>> Or, of course, make all optional parameters part of an array, but it's
>> ugly to have to do:
>>
>> sub foo($bar, @optional){
>>    my $baz =$#optional >= 0 ? $optional[0] : 5;
>>    my $quz =$#optional >= 1 ? $optional[1] : 6;
>> }
>>
>
>   I'd like, à la Perl6:
>
> sub foo ($bar, $baz=5, $qux=6) { ... }
>
>   ... for which signature(&foo)->min == 1 and signature(&foo)->max == 3.
>
>   (Or, if we're going to follow Perl6 nomenclature on the signature object
> as well, that's signature(&foo)->arity == 1 and signature(&foo)->count ==
> 3, I believe.)
>
>   Eventually.
>
>   (I thought we were going to punt on the details of optional parameters
> for now?)
>
>
> Eirik
>

I'm not quite ready to get into optional arguments yet, just pointing out
that the strict vs lax debate can (will?) have repercussions so we don't
block our path forward.

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About