in reply to Re: returning large arrays from functions
in thread returning large arrays from functions

Did the OP, or anyone, ever, suggest that Perl might use a "copy-on-write mechanism"?

  • Comment on Re^2: returning large arrays from functions

Replies are listed 'Best First'.
Re^3: returning large arrays from functions
by ikegami (Patriarch) on Nov 19, 2010 at 07:55 UTC
    You seem to have misunderstood what I said. Whether copying occurs in an array to array assignment or not depends on whether Perl does COW or not. If it does, copying can be avoided. If it doesn't copying must occur. It doesn't, so copying must occur. And thus, the OP's question is answered.

      Perl could recognise that the contents of the internal array, once transfered to the external array, will be garbage collected, and avoid both the copying and the GC, by simple transferring the already allocated and populated internal storage of the internal array to the external array.

      COW does not come into it.

        I see that as a special case of copy on write. COW refers to multiple objects sharing the same data storage until one changes. Copying the pointer over shares the data storage. What's special is that it never reaches the point where copying is necessary. If you'd rather use a different word for it, pretend I used that word.