Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re^5: Preferred technique for named subroutine parameters?

by LanX (Saint)
on May 22, 2009 at 22:06 UTC ( [id://765763]=note: print w/replies, xml ) Need Help??


in reply to Re^4: Preferred technique for named subroutine parameters?
in thread Preferred technique for named subroutine parameters?

I've no possibility to test it ATM, but I think the point is that the hash-refs are passed unchanged into the function. Your right that after my %args = @_; it will be stringified, but at least they can still be found unchanged in @_.

The crucial problem about stringified refs is that normally you have no means to tell which ref corresponds to HASH(0x225398), but in this case you have at least the possibility from within the function to search @_ (or to create a second hash) to find it out!

Cheers Rolf

Replies are listed 'Best First'.
Re^6: Preferred technique for named subroutine parameters?
by AnomalousMonk (Archbishop) on May 22, 2009 at 22:24 UTC
    But surely the point is that if you pass a reference (to whatever, and however generated) as the value of a named parameter in the  func({ foo => [ 1, 2 ] }); scheme, then there is no problem whatever.
      Correct, but the whole discussion is about passing keys not values!

      Cheers Rolf

        My apologies. I thought the whole discussion was about the preferred technique for passing named subroutine parameters: the names wind up being hash keys, i.e., strings, and the parameters wind up being hash values, i.e., anything that can be represented as a scalar, including a reference.

        Another point about which I am still confused is "Try using a reference as a hash key ... " in the reply Re^3: Preferred technique for named subroutine parameters? by akho.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (3)
As of 2024-04-16 21:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found