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

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.

  • Comment on Re^8: Preferred technique for named subroutine parameters?

Replies are listed 'Best First'.
Re^9: Preferred technique for named subroutine parameters?
by LanX (Saint) on May 23, 2009 at 12:10 UTC
    Correct, the thread is about "passing named subroutine parameters"!

    In our = (you, akho, me) whole discussion it's about particularly passing hash keys. If have no clue why your switching the topic now to hash values (?)

    Concerning your confusion ... what's not clear about my first answer? -> Re^5: Preferred technique for named subroutine parameters?

    Cheers Rolf

      In the immortal words of Strother Martin, "what we've got here is failure to communicate!"

      Long ago and far away, the main thread began with a question about passing named parameters as hash key/value pairs: the key is the name and the value is the parameter.

      Subsequently, in Re^3: Preferred technique for named subroutine parameters? and in the context, I thought, of the question of the main thread, akho wrote "Try using a reference as a hash key ... ".

      I think this statement is the root of my confusion, because I would paraphrase it as "Try using a reference as the name of a named parameter", and I could not (and still cannot) understand why one would want to do this.

      Further along in Re^3: Preferred technique for named subroutine parameters? and in sub-threads stemming therefrom, and in Re^5: Preferred technique for named subroutine parameters? in particular, there is discussion, as I understand it, of just what happens to a reference when it gets stringified as a hash key and of how to avoid the ill-effects of this process. But I still cannot answer what, to me, seems the Basic Question: Why would one want to use a reference as the name of a named parameter in the first place?

      Until I can either answer the BQ or clear up any confusion I may have about akho's original statement, I fear I am doomed to endless, hopeless wandering...

        For instance in functional programming anonymous functions are passed around, even in arrays or hashes and then you might even want to assign further data to them.

        I never needed to do this, but it's certainly not useless to do so. You may want to read Higher Order Perl to learn more.

        It wasn't clear that your problem is "what is it good for", you sounded more like "theres no difference".

        Cheers Rolf