Boost logo

Boost Users :

From: Eric Niebler (eric_at_[hidden])
Date: 2008-06-04 10:53:59


Joel Falcou wrote:
> Hello,
>
> I'm currently trying to grasp the way proto trasnform are supposed to
> work and I was wondering fio there is any use cases or examples of how
> and why a Visitor can be used.

Hi,

In the proto/v4 branch, "Visitor" has been renamed "Data" to more
accurately reflect its role as a blob of user-specified data to be
passed along to each transform.

A very simple example is a lambda library with placeholders. Imagine you
wrote a transform that evaluated lambdas with arguments. When evaluating
a lambda expression such as (_1 + _2) with the arguments (3,4), you
might pass the arguments to the transform as a tuple in the Data
parameter (a.k.a Visitor). Then, when the transform has recursed to a
placeholder terminal, say _1, the result would be the 0th element in the
Data tuple.

I have reimplemented the Boost Lambda Library on top of proto using this
technique. You can find it here:

http://svn.boost.org/trac/boost/browser/branches/proto/v4/libs/proto/example/lambda.hpp

HTH,

-- 
Eric Niebler
BoostPro Computing
http://www.boostpro.com

Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net