|
Boost : |
From: David Abrahams (david.abrahams_at_[hidden])
Date: 2001-12-12 15:48:54
----- Original Message -----
From: "Peter Dimov" <pdimov_at_[hidden]>
> Actually there are two levels of non-correspondence. The first level is
when
> the algorithms perform a different operation - like the "copy" you just
> mentioned. In STL "copy" takes one sequence as input and "returns" a
result
> into the second, output, sequence.
>
> The second level is that in pure functional languages (and C++ templates
are
> a pure functional language) there are _no_ mutating operations, while in
> (non-meta) C++ mutating operations are essential.
Yes, I realize that; it was part of what I was trying to point to. But
thanks for making it clearer.
> The STL follows the
> procedural idiom, while a metaprogramming library must, out of necessity,
> follow the pure functional idiom.
I don't think it's so different in all cases. Many (most?) STL algorithms
only need an OutputIterator for their result, which can be used for a
non-mutating output (where there is no pre-existing sequence). For these
algorithms, it certainly makes sense to think of a compile-time counterpart.
> BTW a "functional" push_back(l, v) is simply append(l, cons(v, nil)).
> push_front(l, v) is cons(v, l) (a fundamental operation.)
Yes.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk