Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
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?
[LanX]: Donald Trump's first UK post-election interview
erix is not interested what the imbecile-in-chief has to say -- only what he will do
[GotToBTru]: that sounds fair to me
[davies]: I've just "approved" using syscalls in perl through inline c for at least the third time, but it still appears to me as unapproved. Is this just me?
[LanX]: erix: other side of the pond

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (12)
As of 2017-01-16 14:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you watch meteor showers?




    Results (151 votes). Check out past polls.