COW vs. in-place.

Oskar Linde oskar.lindeREM at OVEgmail.com
Thu Aug 3 09:25:47 PDT 2006


Dave wrote:
> 
> What if selected functions in phobos were modified to take an optional 
> parameter that specified COW or in-place? The default for each would be 
> whatever they do now.

There are at least three ways an array algorithm can operate:
- in-place
- copying
- CoW

In this case, CoW would mean a function that made a copy in all cases 
except when the return value would become identical to the argument and 
as such, is semantically very close to the copying version.

It would make more sense to have separate in-place and copying 
functions, and add a possible runtime CoW-flag to the copying function.

I don't think a runtime flag for CoW vs in-place does make much sense 
when the compile time semantics are different.

An efficient implementation of a copying algorithm would also often be 
quite different from an in-place version, speaking for separate functions.

/Oskar



More information about the Digitalmars-d mailing list