COW vs. in-place.

Dawid Ciężarkiewicz dawid.ciezarkiewicz at gmail.com
Mon Jul 31 11:00:07 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.
> 
> For example, toupper and tolower?
> 
> How many times have we seen something like this:
> 
> str = toupper(str); // or equivalent in another language.
> 
> Thanks,
> 
> - Dave

I don't get it (the example).

str = toupper(str);

does not mean that str can be modified in place

-- BEGIN --
void bla(char[] str) {
  str = toupper(str);
  /* something else */
}

bla("this string is readonly");
--- END ---
If you mean something else - sorry, still I don't get it.

I'd rather wait till const/immutability in D problem will be resolved. Don't
forget that additional "option" is runtime cost. There are some
propositions of const/immutability that could help providing compile time
information to deal with your proposition.



More information about the Digitalmars-d mailing list