develooper Front page | perl.perl6.language | Postings from August 2005

Re: Calling positionals by name in presence of a slurpy hash

Thread Previous | Thread Next
From:
Luke Palmer
Date:
August 23, 2005 08:11
Subject:
Re: Calling positionals by name in presence of a slurpy hash
Message ID:
7ca3f01605082308114085b73c@mail.gmail.com
On 8/23/05, Ingo Blechschmidt <iblech@web.de> wrote:
> Hi,
> 
> (asking because a test testing for the converse was just checked in to
> the Pugs repository [1])
> 
>     sub foo ($n, *%rest) {...}
> 
>     foo 13;
>     # $n receives 13, of course, %rest is ()
> 
>     foo 13, foo => "bar";
>     # $n receives 13 again, %rest is (foo => "bar")
> 
>     foo n => 13;
>     # $n receives 13, %rest is (), right?
> 
>     foo n => 13, foo => "bar";
>     # $n receives 13, %rest is (foo => "bar"), right?

Yep, that's all correct.  Matter of fact, what %rest actually gets has
not been defined. "Maybe %rest mirrors all the named arguments, maybe
it doesn't".  I can see a very small utility if it does, but it seems
like it would be faster[1] if it didn't.  I think it's fair to say no
here.

[1] Yeah, yeah, premature optimization and whatnot.  You always have
the sig (*%hash) if you really want to.

Luke

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