Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2003-10-20 10:13:49

Thorsten Ottosen wrote:
> "Peter Dimov" <pdimov_at_[hidden]> wrote in message
> news:02a001c39712$16d66260$1d00a8c0_at_pdimov2...
>> Thorsten Ottosen wrote:
>>> I and why is it an error? What about this error:
>>> trim( s ); // bug: s is not changed
>>> ?
>> <shrug>
>> 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


instead of


I even find the explicit sequencing preferable, if a bit verbose.

Boost list run by bdawes at, gregod at, cpdaniel at, john at