On Wednesday 13 October 2010 07:10:15 Eric Niebler wrote: > On 10/4/2010 11:51 PM, Thomas Heller wrote: > > Eric Niebler wrote: > >> On Mon, Oct 4, 2010 at 12:43 PM, Thomas Heller
<snip> > > Note: i created a unpack transform which is boilerplate code for the > > > > extraction of the children of the current node. So what it > > does is, that it calls the proto::callable passed as first > > template parameter and is applies an optional transform to > > the children prior to passing it to the callable, > > additionally it is able to forward the data and state to the > > transform > > I had a really hard time grokking unpack. In Proto, function-types are > used to represent function invocation and object construction. The type > "X(A,B,C)" means either call "X" with three arguments, or construct "X" > with three arguments. In "unpack< X(A, B, C) >" X does *not* get called > with three arguments. It gets called like "X( A(_0), A(_1), A(_2), ...B, > C )", where _0, _1 are the child nodes of the current expression. This > will confuse anyone familiar with Proto. I'd like to replace this with > something a little more transparent. Ok, i put to together an alternative version. This hooks onto the already in place transform mechanism and works like this: Whenever the first argument to a transform is proto::vararg<Fun> it expands the child expressions and applies the Fun transform before the actual transform gets called, example: struct test : proto::when< proto::function<vararg<proto::_> > , foo(vararg<proto::_>) > {}; this will call foo(a0, a1 ... aN) where aX are the children of the function expressions. Note that you can replace proto::_ by any transform you like. Thus making the call look like: foo(Fun(a0), Fun(a1), Fun(a2) ...) Additionally, you can add whatever arguments you like to the transform. I think this comes closer to what the user expects, and is more transparent. The implementation can be found at: http://github.com/sithhell/boosties/blob/master/proto/boost/proto/transform/when_vararg.hpp A testcase can be found at: http://github.com/sithhell/boosties/blob/master/proto/libs/proto/test/when_vararg.cpp _______________________________________________ proto mailing list proto@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/proto