The Boost Lambda Library
started 7/31/2002; 9:34:18 AM - last post 8/1/2002; 9:50:19 AM
|
|
Dan Shappir - The Boost Lambda Library
7/31/2002; 9:34:18 AM (reads: 2694, responses: 5)
|
|
The Boost Lambda Library |
The Boost Lambda Library (BLL in the sequel) is a C++ template library, which implements form of lambda abstractions for C++. ... The primary motivation for the BLL is to provide flexible and convenient means to define unnamed function objects for STL algorithms. In explaining what the library is about, a line of code says more than a thousand words; the following line outputs the elements of some STL container a separated by spaces:
for_each(a.begin(), a.end(), std::cout << _1 << ' ');
Look's interesting, but is it worth it? While it does make code more readable, I'm worried about the reaction of programmers not familiar with this library if asked to maintain such code. Also, doesn't implement closures (obviously), but does suggest some workarounds:
int foo(int);
for_each(v.begin(), v.end(), _1 = bind(foo, _1));
Posted to functional by Dan Shappir on 7/31/02; 9:39:15 AM
|
|
|
|
Paul Snively - Re: The Boost Lambda Library
7/31/2002; 9:58:22 AM (reads: 1004, responses: 1)
|
|
There's a tremendous amount of cross-pollination going on between BLL and Phoenix. Phoenix is an adjunct project to Spirit, a parser construction system implemented via template metaprogramming in C++. In fact, in the latest Spirit-X builds, Spirit and Phoenix are completely integrated; see <http://www.geocrawler.com/archives/3/12837/2002/6/0/9063943/>.
It's worth pointing out that one of the things that Phoenix offers is true hardware-stack-based closures in C++. It's really mind-boggling stuff.
|
|
Ehud Lamm - Re: The Boost Lambda Library
7/31/2002; 10:48:20 AM (reads: 1053, responses: 0)
|
|
These were mentioned here before. Two others are FC++ and the lambda library, which led to Boost.
I haven't had the time to study any of these in detail, but they all seem like really cool hacks.
|
|
Paul Snively - Re: The Boost Lambda Library
7/31/2002; 10:47:15 PM (reads: 954, responses: 0)
|
|
The Boost Lambda Library is a more recent version of the lambda library that has been accepted into the Boost collection of libraries. The BLL has been inspired by Phoenix to such an extent that syntax has changed to reflect Phoenix and the BLL is also expected to offer true closures at some point. Phoenix, meanwhile, explicitly mentions the inspiration that it drew from both FC++ and the older LL, while going well beyond them.
My own prejudices, as of this writing, are pretty heavily in favor of Phoenix; it seems to combine the perspicacity of FC++ with the expressive power of LL while adding to the latter with true hardware closures. The integration into Spirit 1.5 is also quite compelling, as I will have a need for Spirit later in a project of mine, and being able to use Phoenix to embed my semantics in my grammar cleanly will be quite helpful.
|
|
Ehud Lamm - Re: The Boost Lambda Library
8/1/2002; 1:33:39 AM (reads: 949, responses: 0)
|
|
Can you give a pointer to more details about Phoenix?
|
|
Paul Snively - Re: The Boost Lambda Library
8/1/2002; 9:50:19 AM (reads: 930, responses: 0)
|
|
|
|
|