Boost logo

Boost :

From: Pavol Droba (droba_at_[hidden])
Date: 2002-11-17 11:26:12

On Sun, Nov 17, 2002 at 02:46:31PM +0100, Thorsten Ottosen wrote:
> ----- Original Message -----
> From: "Pavol Droba" <droba_at_[hidden]>
> > > Your example would become
> > >
> > > if ( lower_cased( trimmed( s ) ) = "ok" )
> > >
> >
> > This naming sounds good enough, just I'm not sure if such a difference
> >between
> > two variants would not make the code less readable. Alfter all both of
> >them are doing
> > the same thing.
> Well, 'trim_in' was not too good either. Basically, we are trying to improve
> on _in, right?
Eighter _in or some something else to copy variants.

I have one idea, but it is probable even more crazy. What about putting each
variant if different namespace.

Then yoou can use copy::trim for copy variant and transform::trim from in-place
variant. Or you can use using namespace for you favorite version and fuly qualify
the other one. I have though about it just a little, probably it is not the best idea.

BTW: Just ot remark that I'm folling the pattern of two variants also for find-replace
functions not just for trim. If woudl be nice the have these two categories consistent.

> > What I don't get is why are you proposing to change return value from Seq&
> >to void.
> > I think it is easier fo write
> >
> > to_lower(trim(to_upper(s)));
> >
> > then
> >
> > to_upper(s); trim(s); to_lower(s);
> Chaining is not always good. How often are one going to do it/need it?
> I would simply write a small foo( String& s ) { to_lower(s); trim(s);
> to_upper(s); }.
> If I do use string manipulation a lot I will probably could reuse foo(); I a
> way chaining
> encourages people to avoid writing small helpers; highly unfortunate IMO.

Small helpers are fine, but I'm not a very big fun of them, because if there are too many
of them, it makes the code less readable. And stacking more operations of the same type
is not new in STL. Look for streams. Even it is something different, the ideas can be used
here as well, and I don't mean just trimming, but any other transformation you can think of.



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