COW vs. in-place.
Dave
Dave_member at pathlink.com
Mon Jul 31 14:34:05 PDT 2006
Jarrett Billingsley wrote:
> "Dave" <Dave_member at pathlink.com> wrote in message
> news:ealack$bjg$1 at digitaldaemon.com...
>> 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.
>
> I've had the same idea; would be great for those trying to write libraries
> that make as few allocations as possible. Not to mention just plain more
> efficient if you don't need a copy.
>
Too much water under the bridge now anyway (or is there?), but I've
often thought that it would've been better to do the same and make
in-place the default and COW the exception anyhow. This wouldn't have
been a hurdle for people coming from the C lib. to Phobos anyway --
they're used to it (e.g.: strcat, et al). As to users of other
languages, all the docs. would have to do is make sure to point out what
in-place means, with maybe an example of how to .dup your string before
you pass it in if needed.
More information about the Digitalmars-d
mailing list