23 Sep 03:59
Re: [Review] Phoenix review starts today, September 21st
Joel de Guzman <joel <at> boost-consulting.com>
2008-09-23 01:59:32 GMT
2008-09-23 01:59:32 GMT
David Abrahams wrote: > on Mon Sep 22 2008, Joel de Guzman <joel-AT-boost-consulting.com> wrote: > >> David Abrahams wrote: >>> on Mon Sep 22 2008, "Peter Dimov" <pdimov-AT-pdimov.com> wrote: >>> >>>> Mathias Gaunard: >>>>> Loïc Joly wrote: >>>>> >>>>>> - How does this library position itself wrt the upcomming C++0x > standard, >>>>> with native support for lambdas, and standardized support for > function or >>>>> bind? Is it more expressive? >>>>> >>>>> The C++0x standard only specifies monomorphic lambdas at the moment. >>>>> So Phoenix is indeed more expressive, since all expressions are polymorphic. >>>> Except phoenix::bind, which is monomorphic, for whatever reasons.>>>> >>>> >> http://www.boost.org/doc/libs/1_36_0/libs/spirit/phoenix/doc/html/phoenix/composite.html#phoenix.composite.bind> >>> Hmm, that seems like it will needlessly restrict generic code. >> Ah that one. I think that needs clarification. The note is wrong >> and should be corrected. A bound function pointer or member function >> pointer is only monorphic once bound (of course -- a single function >> pointer or member function pointer is monomorphic). The same is true >> with bind and lambda bind. > > Yeah, but what about a bound polymorphic function object? The doc makes > it sound like passing through bind removes that polymorphism. > >> Phoenix bind, like bind and lambda bind is polymorphic at the call >> site in the sense that it can bind to any function and function >> pointer and function object (which can be polymorphic). One problem >> I notice now with the bind documentation of phoenix is that it >> lacks the function object binding part. >> >> Noted for correction. Pardon the confusion. > > I'm still confused
You can disregard the note. It is a historic artifact from V1 and is not accurate. Phoenix2 *can* bind to polymorphic function objects. Example: struct sqr { template <typename Arg> struct result { typedef Arg type; }; template <typename Arg> Arg operator()(Arg n) const { return n * n; } }; ... BOOST_TEST(bind(sqr(), arg1)(i5) == (i5*i5)); Regards, -- -- Joel de Guzman http://www.boostpro.com http://spirit.sf.net _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
>>>>
>>>>
>>
You can disregard the note. It is a historic artifact from V1 and
is not accurate. Phoenix2 *can* bind to polymorphic function objects.
Example:
struct sqr
{
template <typename Arg>
struct result
{
typedef Arg type;
};
template <typename Arg>
Arg operator()(Arg n) const
{
return n * n;
}
};
...
BOOST_TEST(bind(sqr(), arg1)(i5) == (i5*i5));
Regards,
RSS Feed