Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
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).


Comment on Re: Why doesn't Perl provide %_ as the hash equivalent of @_ in subs?
Select or Download Code

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 lurking in the Monastery: (13)
As of 2014-08-22 12:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (156 votes), past polls