Boost logo

Proto :

Subject: Re: [proto] Thoughts on traversing proto expressions and reusing grammar
From: Thomas Heller (thom.heller_at_[hidden])
Date: 2010-10-13 01:35:33

On Tuesday 12 October 2010 22:37:06 Eric Niebler wrote:
> On 10/12/2010 1:24 PM, Eric Niebler wrote:
> > So it really seems to me that transform_expr is not necessary, but I
> > may be wrong.
> I just confirmed this by trivially replacing uses of transform_expr with
> appropriate uses of nary_expr in your phoenix_test.cpp (attached).
> The only difference is the type of the last expression. Since
> pass_through transform leaves terminals alone, _1 ends up stored by
> reference in the transformed expression, which is perfectly OK and saves
> copies (admittedly trivial in this case).

You are right, transform_expr can be replace by nary_expr. transform_expr is
a little less verbose but not as flexible, I admit.
The motivation behind transform_expr to have something similiar to fold to
resemble these "standard" algorithms like fold and transform without
noticing they are already there. So I guess it would be a nice addition to
the docs to have a mapping between algorithms people already know to how to
express it with proto.

Proto list run by eric at