
On Wed, Apr 2, 2008 at 1:59 AM, shunsuke <pstade.mb@gmail.com> wrote:
Giovanni Piero Deretta wrote:
BTW, Boost.Egg has the potential to implement your compose.
typedef result_of_lazy<fold>::type fold_; typedef result_of_lazy<reverse>::type reverse_; typedef return_of<fold_(reverse_(T_bll_1), T_bll_2, T_bll_3)>::type reverse_fold;
Oh! So Egg has the functionality to make function objects directly usable in lambda expressions (without bind)??? i.e.
for_each(range_of_ranges, regular(protect(std::cout << accumulate(ll::_1, 0))))
does that actually work? (for appropriate definitions of for_each and accumulate, of course). I was going to ask you to provide this functionality in egg (yes, I'm working on a review :) )
Yes. egg::lazy/nestN makes bind/protect deprecated. I've noticed that bind/protect is a customization point. e.g.
X_lazy<T_boost_bind> bb_lazy; // T_boost_bind represents boost::bind. bb_lazy(foo)(::_1, 2);
In fact, implementing T_boost_bind is so difficult that Egg skips it. :-)
BTW, i prefer to spell 'regular(protect(...))' as 'lambda[...]'
What is `regular`? Is it the same as egg::regular?
yes, exactly. I do not have a 'regular' function, I've just used this name because this is what egg uses.
BTW, everything must be function-call to support result_of.
What do you mean exactly with "everything must be function call?".
Even if I guarantee that my function objects (in this case fold and reverse) are stateless? Does using the lambda placeholders complicate things?
If fold_ is DefaultConstructible and a default-constructed one is callable, it would be:
typedef static_< mpl::always< return_of<T_regular(fold_(reverse_(T_bll_1), T_bll_2, T_bll_3))>::type > > reverse_fold;
I tend to hesitate to use result_of/return_of without function-calls.
Again, what do you mean exactly? And why do you esistate? I'm evaluating egg design, so these answers would be very valuable.
So your `compose` may be a candidate of yet another lambda framework.
As if there weren't already enough :) -- gpd