From: Peter Dimov (pdimov_at_[hidden])
Date: 2003-10-20 10:13:49
Thorsten Ottosen wrote:
> "Peter Dimov" <pdimov_at_[hidden]> wrote in message
>> Thorsten Ottosen wrote:
>>> I and why is it an error? What about this error:
>>> trim( s ); // bug: s is not changed
>> std::sin(x); // bug: x is not changed
>> FWIW, I much prefer the functional style in this case.
> My point was that (most) verbs in the imperative means mutation,
> nothing else. I expect
> mutation to happen in those cases. I also expect a function called
> remove() to mutate the input and
> I consider a different behavior very strange.
In this specific case, I don't expect or want mutation by default; strings
are logically much closer to immutable values than they're to stateful
objects, and string operations in most languages reflect that.
Naming aside, a non-void return from inplace mutators is, IMO, a mistake,
too. There is never a _need_ to chain inplace mutators; you can always write
I even find the explicit sequencing preferable, if a bit verbose.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk