Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: Why doesn't Perl provide %_ as the hash equivalent of @_ in subs?

by moritz (Cardinal)
on Sep 26, 2013 at 15:10 UTC ( #1055855=note: print w/ replies, xml ) Need Help??


in reply to Why doesn't Perl provide %_ as the hash equivalent of @_ in subs?

There are at least four commonly used calling conventions for named arguments in existing Perl 5 code:

yoursub(a => 1); yoursub({ a => 1 }); $obj->meth(a => 1); $obj->meth({a => 1});

In addition, people like to mix positional arguments with named arguments, for example from AnyEvent::HTTP:

http_get $url, timeout => 20, sub { # callback here };

No, introducing %_ doesn't even begin to cover the use cases that are out in the wild, and it's another legacy feature that needs to be supported when/if proper routine signatures are introduced.

And that is the thing that should be done. There are several promising modules on CPAN that provide proper routine signatures, most of which converge on the syntax that Perl 6 uses. Getting one of them rock solid and into core Perl 5 would be a much better solution. (And I believe people are working on it already).

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1055855]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (14)
As of 2016-06-29 20:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My preferred method of making French fries (chips) is in a ...











    Results (387 votes). Check out past polls.