Re: C++ Online Reference
On Oct 12, 12:53 pm, Michael DOUBEZ <michael.dou...@free.fr> wrote:
James Kanze a =E9crit :
The English word "remove" is incorrect with regards to what
std::remove does. If you insist on using it, as the SGI
specification does, it is essential to describe exactly what you
mean by it, since the "normal" English meaning will result in a
misunderstanding.
Well, you know best. English is not my native tongue.
I'm not sure it's mine any more either---I haven't used it on a
regular basis for close to 40 years. (I'm not sure I have a
native tongue. I feel most at home in French, but any Frenchman
will spot my accent a mile off.)
Googling for the definiton of remove:
[...]
There are a number of very good on line dictionaries as well;
you don't even have to Google (and you know exactly how reliable
the source is). There are uses of remove whose meanings could
be more or less understood to apply. They're simply not the
ones we "expect" in this context.
The proof, of course, is the number of people who are confused
by it, and expect it to remove something from somewhere.
...
Since the parameter of the std::remove() algorithm is a range and
considering the above definition, IMHO 'remove' is not that bad.
Perhaps 'strip' would have been more meaningful.
I think that part of the problem is that "remove" is expected to
act on the sequence itself. Within the C++ community, at least,
I don't think that most people think in (or expect) functional
programming idioms. What the function really does (sort of) is
create a new sequence which contains all of the elements in the
original sequence, in order, except those it "removed". Except,
of course, that the "new sequence" isn't really new.
I suspect that Lisp programmers would feel right at home with
the name; from what little I've seen, they're quite used to the
functional programming idiom, and sharing parts of a list (a
sequence).
And while I don't like the name, I can't really think of a
better one, either. But the easiest way to explain it to a
beginner is to start by saying something along the lines of
"remove doesn't really remove", which really suggests very
strongly that the name isn't the right one.
Removing from a container is more related to 'erase' (google
again) because it relate to the storage system:
Except that "erase" isn't that often used in computer circles
for that operation. In my first container class (very, very
pre-standard), I used "delete", which I found perfect. The
compiler didn't however, and I was forced to change it---to
remove. (To me, erase suggests erasing something from a
blackboard, or pencil marks from a piece of paper. The
information is lost, but the support is still there. Something
like filling an array of int with 0's.)
erase: 1. To obliterate information from a storage medium, such as to
clear or to overwrite. 2. In a magnetic storage medium, to remove all
stored data by (a) changing the medium to an unmagnetized state or (b)
changing the medium to a predetermined magnetized state. 3. In paper
tape and punched card storage, to punch a hole at every punch position.
Hence the member function Container::erase() I guess.
From the above definition, I think that the names are reversed;
erase clears or overwrites (without removing the elements).
Perhaps part of the problem with remove, here, is that generally
within the STL, one thinks in terms of elements, and not values.
Remove "defines" a new sequence with the relevant values
removed, but does not remove elements.
--
James Kanze (GABI Software) email:james.kanze@gmail.com
Conseils en informatique orient=E9e objet/
Beratung in objektorientierter Datenverarbeitung
9 place S=E9mard, 78210 St.-Cyr-l'=C9cole, France, +33 (0)1 30 23 00 34