in reply to Re: How to swap scalar values without copies
in thread How to swap scalar values without copies

(I see now the update, and I don't know how to update my reply in turn ...).

Swapping the values of the references does not waste memory, but it violates rule n.2, namely that I want $a to be a string, not a reference to a string.

Replies are listed 'Best First'.
Re: Re: Re: How to swap scalar values without copies
by hardburn (Abbot) on Feb 20, 2004 at 00:16 UTC

    I don't think you can have it both ways. You either need to work around having a reference or live with the major memory requirement. I'm not an XS-guru, but it appears Data::Swap just does the reference stuff for you.

    ----
    : () { :|:& };:

    Note: All code is untested, unless otherwise stated

Re: Re: Re: How to swap scalar values without copies
by Anonymous Monk on Feb 20, 2004 at 02:04 UTC
    That is a very stupid requirement. You're creating a problem where one doesn't exist.
      Thanks for your insightful contribution