Boost logo

Boost :

From: Daniel Walker (daniel.j.walker_at_[hidden])
Date: 2008-06-06 12:16:51


With all the recent discussion about Functional Programming, I thought
I'd take a closer look at some of the FP libraries that I haven't
really used before, and I started last night by browsing through
Phoenix's documentation. This led me to a few questions:

Does Phoenix allow side-effects or is it "pure" functional like Fusion
and FC++? Does it allow modification of arguments by reference -
either builtin references or reference_wrapper?

What is the status of the Phoenix msvc port? The documentation seems
to indicate that it's possible but not necessarily forthcoming.

Is there any immediate plan to make Phoenix interoperable with the
coming standard library's std::bind, std::placeholders,
std::is_bind_expression, and std::is_placeholder?

Regarding Boost.Bind, will it eventually support is_bind_expression? I
mean will it treat types for which is_bind_expression is true as
full-blown bind sub-expressions? (I know it's a matter of time and
work and testing to get this, and I'd be willing to help out, write
test cases, whatever's needed.)

Also, Peter, weren't you thinking of proposing operator overloads for
bind expressions in C++0x? I think you have some already implemented
in Boost.Bind. Do you think operator overloads are likely to make it
into the final draft?

Finally, I noticed the Phoenix documentation cites BLL and FC++ as
major influences. I'm fairly familiar with BLL (with its
implementation and usage, rather than its history) but not at all
familiar with FC++. I hope at least to skim through the documentation
over the next few days.

However, one thing I noticed right away while reading about Phoenix
was that it borrows the term rank-2 polymorphic function from FC++.
I'm just learning this terminology, so I'm trying to gain confidence
that I understand it. From briefly skimming (McNamara, 2000) in JFP,
I'm under the impression that a rank-2 polymorphic function can only
have two parametric types, i.e. two template parameters. So, for
example, std::make_pair is rank-2 polymorphic, and FC++ has functions
that will produce pairs when called with two different types. A rank-n
polymorphic function can have arbitrarily many different template
parameters; an example would be std::make_tuple. Doesn't Phoenix
actually support rank-n polymorphism? For example, isn't the following
a rank-3 polymorphic function in Phoenix and couldn't you write
similar function objects for higher ranks?

struct tupler_ {
    template<class> struct result;

    template<class F, class T0, class T1, class T2>
    struct result<F(T0,T1,T2)> {
        typedef tuple<T0,T1,T2> type;
    template<class T0, class T1, class T2>
    tuple<T0,T1,T2> operator()(T0 t0, T1 t1, T2 t2) const
        return make_tuple(t0,t1,t2);
phoenix::function<tupler_> tupler;

One last thing - I noticed that FC++ was submitted for inclusion in
Boost a few years back. What ever happened with that?

Thanks in advance!
Daniel Walker

Boost list run by bdawes at, gregod at, cpdaniel at, john at