Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

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

by choroba (Canon)
on Sep 26, 2013 at 09:58 UTC ( #1055804=note: print w/ replies, xml ) Need Help??


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

Nice idea, really. I am just not sure how to make it work with objects: the first parameter is a class or an object reference, the named parameters follow.

لսႽ ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ


Comment on Re: Why doesn't Perl provide %_ as the hash equivalent of @_ in subs?
Replies are listed 'Best First'.
Re^2: Why doesn't Perl provide %_ as the hash equivalent of @_ in subs?
by smls (Friar) on Sep 26, 2013 at 10:07 UTC

    Hm, good point.
    I guess it could be made so that in case of an uneven sized list, it excludes the first item.

    But that would break consistency with regard how uneven lists are usually interpreted as hashes, which I think is to exclude the last item and printing a warning.

      Or, maybe, the hash is created once you use the variable for the first time, so you can safely shift the $self or $class.
      لսႽ ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (4)
As of 2015-07-30 01:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (269 votes), past polls