xxxInPlace or xxxCopy?

spir denis.spir at gmail.com
Fri Jan 21 12:15:42 PST 2011


On 01/21/2011 07:47 PM, so wrote:
>> replace is clearer in the first case, because you're getting the
>> return value.
>> ...
> I am really trying hard to understand this, but your reasons for first
> is clearer then the second makes no sense to me i am sorry.
> I still think second is clearer, but whatever, as long as i can see the
> interface or the doc, i am fine.
>
> string replace(string, ...);
> void replace(ref string, ...);
>
>> Regardless, I don't see anything wrong with naming functions in a
>> manner that
>> implies that a functional style is the default
> I am not against enforcing such a rule, i am against doing it implicitly
> and work with assumptions.
> Just check boost/string/replace, they have in place replaces default
> too. You might not like boost (some don't) but it is the closest example
> to D.

Without any additional information, I would necessirily assume replace 
performs an /action/ because it's an action verb: meaning it changes the 
argument. Like 'so', I cannot understand the converse reasoning.
I you want people to guess that a true function returns a result, just 
name it according to its result: replacedString, ot just replaced. 
Nobody, I guess, would ever think that a routine called replacedString 
acts in-place.

Denis
_________________
vita es estrany
spir.wikidot.com



More information about the Digitalmars-d mailing list