[Boost::mpl] transforming expression both at compile time and runtime
Can someone guide me how to transform an expression both at compile time and at
runtime? I explain by an example
Suppose I want to transform the following expression like that
foo(f,other(g,bar)) --> other(g,foo(f,bar)) where bar is an Array and the "foo"
and "other" are the higher order functions.
I can write the metafunction for transforming the type of the expression i.e from
Foo
Sounds like a job for Boost.Fusion ;)
On 16/08/10 16:55, Noman Javed wrote:
In that case I have to first transform the expression into a fusion sequence and then apply my own transformations. Am I right? More or less yes depending on the nature of your original expression. Fusion is basically the bridge between compile-time and runtime manipulation.
joel falcou wrote:
On 16/08/10 16:55, Noman Javed wrote:
In that case I have to first transform the expression into a fusion sequence and then apply my own transformations. Am I right? More or less yes depending on the nature of your original expression. Fusion is basically the bridge between compile-time and runtime manipulation.
Isn't that the perfect use for a nice first transformation for phoenix3?
On 8/16/2010 10:43 AM, joel falcou wrote:
Sounds like a job for Boost.Fusion ;)
A-hem, it sounds more like a job for Boost.Proto, which is specifically designed for transforming C++ expressions both at compile time and runtime. The op said:
foo(f,other(g,bar)) --> other(g,foo(f,bar))
If foo and other are proto expressions (which be easy to engineer), this expression will generate a proto expression tree that you can pass to a proto transform to do anything you want. -- Eric Niebler BoostPro Computing http://www.boostpro.com
On 16/08/10 18:16, Eric Niebler wrote:
A-hem, it sounds more like a job for Boost.Proto, which is specifically designed for transforming C++ expressions both at compile time and runtime. Yeah, I saw the holy light right after my initial message and corrected :o
Zitat von Noman Javed
Can someone guide me how to transform an expression both at compile time and at runtime? I explain by an example
Suppose I want to transform the following expression like that foo(f,other(g,bar)) --> other(g,foo(f,bar)) where bar is an Array and the "foo" and "other" are the higher order functions.
I can write the metafunction for transforming the type of the expression i.e from Foo
> --> Other > I want to execute this expression in the following way Array result = foo(f, other(g, bar)) where within the body of the operator= overload of the Array class I have the function transform to transform this expression as said above.
if I understand you correctly you want to pass a function object to operator= and transform it? then your C++ syntax would be: Array result = bind(foo,f,bind(other,g,bar)); if so, I'm not aware of any way to "extract the curry" out of a bind() result. the functional stuff in Boost.Fusion (fused function objects) might be helpful in building such a bind(). joel, has there been an attempt to make Fusion and Bind work together in this way? the result of a bind() could be expressed as a fused function object plus a fusion sequence. but bind() seems to store the arguments in its own argument list type, and doesn't expose it.
On 16/08/10 17:35, Stefan Strasser wrote:
joel, has there been an attempt to make Fusion and Bind work together in this way? the result of a bind() could be expressed as a fused function object plus a fusion sequence. but bind() seems to store the arguments in its own argument list type, and doesn't expose it. I don't think it does. Mayeb that's something the proto based phoenix3 can help with as the very structure of the bindign will be introspectable.
participants (5)
-
Eric Niebler
-
joel falcou
-
Noman Javed
-
Stefan Strasser
-
Thomas Heller