http://www.perlmonks.org?node_id=11124513


in reply to Concatenation with empty string -- good enough to force physical copy?

Basically you're trying to defeat perl's copy-on-write optimisation. Concatting an empty string will currently do this, but there are no future guarantees. If you want your code to be robust you really need to handle this at the C level.

Dave.

  • Comment on Re: Concatenation with empty string -- good enough to force physical copy?

Replies are listed 'Best First'.
Re^2: Concatenation with empty string -- good enough to force physical copy?
by vr (Curate) on Dec 03, 2020 at 06:59 UTC

    Exactly, word "CoW" was on my mind but somehow omitted when re-phrasing the question. Thank you for sharing your insight. As there's no "idiom" apparently (but wouldn't it be nice... concatenation with compile time constant treated as such), the trick with side-effect should better be avoided.