std.stringbuffer
Frits van Bommel
fvbommel at REMwOVExCAPSs.nl
Thu May 1 08:29:04 PDT 2008
Bruno Medeiros wrote:
> Frits van Bommel wrote:
>> The modifying versions should have some distinguishing characteristic
>> to separate them from the COW versions. I'd say either a different
>> function name or an extra out-buffer parameter (as long as they still
>> work if the buffer is the same array as the normal input).
>
> Yes, the idea to distinguish them with a different name sounds good
> (names like "doToUpper", maybe?). So that means you agree it should be
> in the same package? :P
I don't like 'doToUpper', but something like 'makeUpper' could be a good
convention. That makes it pretty clear they're modifying the input, I think.
I don't particularly care what package they're in, but their names
should make it clear what they do. Especially if you're working with
both sets of functions in the same module...
Looking at the Phobos2 std.string docs, I do think some of those
functions could benefit from at least a const(char)[] overload so
they'll work with non-invariant parameters too. The ones that don't even
return string data[1] should probably just replace all invariant
parameters with const ones.
Of course, for the rest the return type of const overloads could be
debated. (First question: should they ever return a slice? If not,
should the return type be mutable or invariant[2]?)
[1]: In particular: inPattern(), size_t count*(), bool is*() and size_t
column() are the ones I saw.
[2]: It shouldn't be const though, that'd be pointless: returning newly
allocated memory as const means it's effectively invariant anyway.
More information about the Digitalmars-d
mailing list