in reply to Re^3: Using a tied scalar as an in memory file
in thread Using a tied scalar as an in memory file

You thought the variable was being passed directly, so you believed the SV was being passed by reference. In the same breath, you said tied variables don't work because SVs are passed by value. I called fouled on the latter, so I don't see how the typical practices of subs are of any consequence here.

Furthermore, we weren't talking about subs, so the typical practices for writing subs are completely irrelevant. (Builtin and other XS) functions access the SV directly until a specific native type is needed. I don't think I've ever seen one that copies the arguments on entry. Remember, the primary purpose of copying the args in subs is to provide named parameters, but functions already have named parameters.

  • Comment on Re^4: Using a tied scalar as an in memory file

Replies are listed 'Best First'.
Re^5: Using a tied scalar as an in memory file
by ELISHEVA (Prior) on Feb 22, 2009 at 13:12 UTC
    Actually, I was talking about subs (though I realize now I may have confused you by using the word sub/function interchangably). From my original reply:
    When scalars are passed to a function, e.g. open they are copied (not passed by reference).

    I was wrong about them not being passed by reference to subs/functions (i.e. the calling convention), but not about them being copied, at least when people use the parameters the usual way. I was mistaken precisely because whenever I define subs I never use @_ directly. As a result, I formed a long standing misimpression of the calling convention. I simply didn't want others to make the mistake I did or to think that they could freely pass tied scalars into subs (or functions) without knowing how they were going to be used internally.

    As for "crying foul" - that makes this sound like a fight. I'm here to learn, not to argue. Perhaps those aren't your goals?

    In my opinion, trying to understand why someone made a mistake is as important as correcting them. And for me, it is an essential part of not repeating my own. I never was much of a rote learner.

    Best, beth

      Actually, I was talking about sub

      I agree that you were talking about subs, which is off-topic and misleading. Especially considering you specifically emphasised open which is not sub, and its arguments aren't passed to it by value.

      As for "crying foul" - that makes this sound like a fight.

      I don't know where you got that idea, but it's not the case.

      In my opinion, trying to understand why someone made a mistake is as important as correcting them.

      Indeed. And it had nothing to do with passing by value.

      Perhaps those aren't your goals?

      My goal was to help the OP, to which you were doing a disservice by providing the wrong explanation.