From: Pavol Droba (droba_at_[hidden])
Date: 2003-10-23 16:39:44
On Thu, Oct 23, 2003 at 03:10:52PM -0400, David Abrahams wrote:
> Pavol Droba <droba_at_[hidden]> writes:
> > I understand very well the pronciples of functional programming. But
> > functional language execute the program in totaly different way then
> > imperative like C++.
> C++ is a multiparadigm language. Many of us like to do functional
> programming in C++. See Boost.Spirit/Phoenix, Boost.Bind,
> Boost.Lambda, FC++, Boost.MPL, ...
Although it it possible to use functional style of programming, and
it makes sense to do it so, C++ will never be a functional language.
Main difference between C++ and f.e. a Haskell is not in primitives
it provides, and the syntax it gives, rather in the way the computation
In normal C++ program, the execution is performed in the means of assigments
and jumps. In Haskell, it is a term rewriting.
> ?? We're not talking about making a copy, since the result differs
> from the input. In general, you pay the same price in functional
So there is realy NO copy performed in Haskell when evaluating the function,
it is a transformation. And this is much closer to inplace version,
in C++ then to copy one.
In copy variant, we are actualy making a copy of the input. That is the actualy
the difference between copy and inplace variant.
I know now you can argue, that we can do the same thing in C++ as Haskell can do.
And for instance MPL is doing it. C++ being turing complete, you
can do virtual anything, but still, but at the end everything will
be wrapped in nice imperative code.
There makes no sense to argue about anyone's personal preferences. They are "personal"
for a reason after all. What I'm trying to find out is a reasonable balance between
There is a awful lot of C++ coders who prefer this language because of its performance.
It is one of major advantagas of C++ in comparation to competitors like Java, scripting
or functional languages.
C++ lacks many features that others have granted in favor to performance. And safety is one
of the major issues. My personal experience is that typical C++ program is well aware
of dangers he can encounter and he is prepeared to take a reasonable risk.
So I consider the favoring of the inplace version, with a basic safety belt (void return), as
a reasonable compromise.
And the last words for this topic. Given the fact, that this particular issue is realy only
a matter of personal preference, I will try to keep the track of reviewer votes and
at the end I will decide which path to take, depending on the number of votes ...
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk