From: Douglas Gregor (gregod_at_[hidden])
Date: 2002-01-21 15:01:59
On Monday 21 January 2002 01:22 pm, you wrote:
> What do you think about the name "take"?
It doesn't give as much information as, say, "get_first" would (IMHO). Or
even something like "front_N" would make more sense to me.
> I think that 'remove_first' certainly sounds more like STL,
> but "drop" and "take" don't seem to have close enough relatives in
> STL, so that the names could just be borrowed.
I think that's my goal - to sound more like STL. Here's why:
Effective use of the STL requires a large vocabulary already, and we can
reasonably expect a competent C++ programmer to know what most of the STL
algorithms do, roughly. By naming the Preprocessor library's routines after
STL routines, we immediately capitalize on that knowledge. Then code that
uses the Preprocessor library looks a little like code that uses the STL, and
it requires less programmer effort to understand.
Of course, this depends on the programmer: a Haskell programmer would
immediately recognize the names "drop" and "take" and understand the
concepts; an STL programmer would recognize more STL-ish names ("front_N",
"remove_first", etc.). I don't believe that we can reasonably expect a
competent C++ programmer to know the vocabulary of Haskell (it's a different
language, with different goals, etc) but the STL is part of C++, so a C++
programmer should know it.
As a disclaimer: I've not ever used Haskell, and my functional programming
experience is quite limited in that I've only stumbled my way through LISP
and ML on occassion; most of my functional programming-like work has been in
writing template metaprograms. Yet on the C++ side I use STL essentially
> I think that "remove_first" sounds like it would work like "tail"
> or "head" (depending on which part, "head" or "tail", is returned).
"remove_first_n" crossed my mind as well; that's likely a better match that
"remove_first", though it's longer.
> So, you like "fold_left" and "fold_right"?
> I considered using "accumulate" (and "reverse_accumulate"
> and "accumulate_left", etc...), but IMO it sounds way too arithmetic.
> Also "fold" is well known concept in functional programming.
> Furthermore I don't want to make it appear as if either one of the
> folds would be more primitive.
Looking at the folds again, it looks to me like std::transform(). Just to be
pesky, I think "fold_left" would work well as "transform" and "fold_right"
would be "reverse_transform."
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk