Boost logo

Proto :

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


On Thursday 14 October 2010 01:58:16 Eric Niebler wrote:
> On 10/4/2010 12:20 PM, Thomas Heller wrote:
> > On Mon, Oct 4, 2010 at 8:53 PM, joel falcou wrote:
> Joel, I don't recall this particular problem or being unable to solve it
> with Proto transforms.
>
> > The split example was one of the motivating examples, that is
> > correct, though it suffers the exact points Eric is criticizing. The
> > split example was possible because i added some new transforms which
> > proto currently misses, but i didn't want to shoot out all my
> > ammunition just yet :P
> >
> > But since you ask for it:
> >
> > http://github.com/sithhell/boosties/blob/master/proto/libs/proto/test/s
> > plitter.cpp
> >
> > the new thing i added is transform_expr, which works like
> > fusion::transform: It creates the expression again, with transformed
> > child nodes (the child nodes get transformed according to the
> > transform you specify as template parameter
>
> If the theory is that this particular problem cannot be implemented with
> existing Proto grammars and transforms, then I submit the attached
> solution as contrary evidence. I'll admit that it doesn't have the
> property that the transforms can be substituted post-hoc into an
> existing Proto algorithm, but is that really necessary? There is no
> grammar to speak of; *every* expression is a valid split expression.

Sorry, i think i wasn't clear enough:
The splitter i wrote was _no_ good demonstration of the visitor. As you
demonstrated, it is much easier to follow with regular grammar + transforms!

> This solution is much, much simpler than Thomas' solution that uses a
> visitor. Heck, it took me longer to understand Thomas' code than it did
> for me to write the solution using standard Proto components.

Indeed! Nice work! Thanks for teaching us again :)

> Still not seeing the big picture with visitors,

I wrote down the evolutionary process that lead me to the "visitor". Please
see my other post and reevaluate.


Proto list run by eric at boostpro.com