Boost logo

Boost Users :

From: Markus Werle (yg-boost-users_at_[hidden])
Date: 2003-01-27 16:05:46


Peter Dimov wrote:

>
> boost::function is a separate library. It can be used with boost::bind,
> and it can be used with Lambda.
>
> I asked you whether you have a particular reason to prefer boost::bind
> over boost::lambda::bind.

Oh, it was just for historical reasons: I built a 2000 line header
which creates boost::functions out of compile-time differentiated
expression templates and I just do not want to repeat that task
in the near future. The header did undergo heavy testing and
so switching that part to boost::lambda would be loosing two weeks
of headache for nothing.

Now I started iterating over arrays of boost::functions
and found that boost::lambda had some nice gimmics like e.g.
if_then_else_return or throw_exception, which I like to use

I did not take the time to see if other parts of boost provide the
same functionality, so maybe this is my fault ...

OTOH I still cannot see why _any_ part of boost should
be outside of namespace boost, since this can always
interfere with what already exists or what will come in the
future, therefore again - despite the possibility of a
merge of boost::lambda with the rest:

I find that if I want to use _1, etc (the arg<1>()) I should
be asked to define a prepro constant (BOOST_USE_PLACEHOLDERS),
not the other way round.
Maybe user's code should look similar to

-------------------- user.C --------------------------
#include "boost/convenience.h "

using namespace boost::convenience;
------ EOF ----------------------------------

-----boost/convenience.h:------

namespace boost { namespace convenience {

using boost::placeholders::_1;
using boost::placeholders::_2;
//etc.

}}
----- EOF ------------------
>
>> Is there a 1-to-1 correspondencce in functionality?
>
> Almost. The differences between boost::bind and lambda::bind are
> enumerated here:
>
> http://www.boost.org/libs/lambda/doc/ar01s08.html#id2808613

let me cite the link You gave:
 "The libraries can coexist, however, as the names of the BB library are
 in boost namespace, whereas the BLL names are in boost::lambda namespace."

Well said, but untrue for _1;

>
>> I just argue that it _should_ be possible to use both of them
>> in the same compilation unit without name clashes. This is what
>> namespaces originally were invented for ...
>
> Historically, conflicts between Bind and Lambda were almost never a
> problem, since there is rarely a reason to use both; the two libraries
> complement each other as Bind is typically used on non-conformant
> compilers where Lambda is not supported.

I see.

>
> The long term goal has always been to have one library. Unfortunately, the
> underlying architectures of Bind and Lambda are too different and it's not
> easy to just merge them while still retaining support for MSVC 6, for
> example. So it's a case of "if it ain't broken, don't fix it".

OK, but how about adding two lines that put _1 in namespace
boost::placeholders?

best regards,

Markus


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net