Boost logo

Boost :

From: Daniel Frey (d.frey_at_[hidden])
Date: 2003-10-23 17:03:49


On Thu, 23 Oct 2003 21:10:52 +0200, David Abrahams wrote:

>> 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, ...

And it's not just a question of language design or paradigm. It's also a
matter of experience. FWIW, my experience is that functions that modify
their arguments are usually best avoided. They tend to cause bugs, no
matter how you argue why this and that should not happen. It happens.

Sometimes they are the least evil, but in this case (the string algorithm
library), I need a convincing reason to make them the default.
Optimizations are always optional and explicit optimizations (through
_inplace) are acceptable.

>> In C++ making a copy means a considerable overhead, in functional
>> languages, no copy is created, rather a term is reduced.

Don't overrate those optimizations. For 90% of your code, no optimizations
are needed and for the other 10%, _inplace is not a big price to pay.

> Sure, it's not always the best approach. It's still the safer approach,
> and I prefer the safer approach to be more convenient.

Me too, although the current void-return-version is at least ways safer
than the original version.

Regards, Daniel


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk