|
Boost : |
From: Aleksey Gurtovoy (alexy_at_[hidden])
Date: 2001-12-14 08:25:24
Peter Dimov wrote:
> From: "David Abrahams" <david.abrahams_at_[hidden]>
> > From: "Peter Dimov" <pdimov_at_[hidden]>
> >
> > > Renaming 'append' to 'push_back' is not simply unnecessary, it's
> harmful.
> >
> > That's an interesting point of view that I never expected. Why is it
> > harmful?
>
> Because it's not a push_back.
>
> push_back(c, v) is a mutating operation on c.
c.push_back(v) is a mutating operation on c. There is no free 'push_back(c,
v)' function in the standard library.
> After it c has one additional element pushed to its back, v.
That's how _you_ decided to define it.
>
> append(a, b) is a pure function that returns the
> concatenation of a and b.
There is no free 'append' function in the standard library. There is an
family of overloaded 'append' member functions in 'std::string', and they
are mutating. For a C++ programmer, there is nothing inherit in 'append'
name that makes it more "pure" than 'push_back', or that implies the
non-mutating semantics. And there is nothing inherit in 'push_back' that
should prevent one from reusing the name in the domain where everything is
non-mutating, if she thinks that such reuse would be beneficial. Sorry, but
I think that stating that compile-time 'push_back<S, T>::type' expression is
"harmful", while 'append<S,T>::type' is not, is an unjustified exaggeration.
Aleksey
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk