Boost logo

Boost :

Subject: Re: [boost] Rave for proposed Boost.Local (functions)
From: Thomas Heller (thom.heller_at_[hidden])
Date: 2011-02-03 10:45:21

Joel de Guzman wrote:

> On 2/3/2011 5:44 PM, Mathias Gaunard wrote:
>> On 03/02/2011 01:19, Joel de Guzman wrote:
>>> On 2/3/11 7:13 AM, Mathias Gaunard wrote:
>>>> Doing anything non-trivial with Phoenix requires creating lazy
>>>> functions beforehand (typically done at namespace scope).
>>>> The fact that Phoenix itself bundles many lazy functions for any other
>>>> container member and standard algorithm (for a total of 4,000 lines of
>>>> code for that task alone) is testament to that; you can't really work
>>>> with it otherwise.
>>> If you unwrap the macros from Boost.Local, something like a
>>> Phoenix.function will emerge. So, why not just provide a phoenix
>>> macro to give you the same level of verbosity and the same level
>>> of debuggability and c++ syntax error handling?
>>> It is trivial to write such a macro in phoenix.
>> Consider I want to write a function that does + _3.baz.
>> If I did as you suggested, I would end up writing three macro invocations
>> before finally being able to write a readable phoenix expression.
>> shortest syntax possible in C++03 -- return type could be avoided in
>> C++0x -- (with Tn to be replaced by actual types):
>> SHORT_FUNCTION(T2, foo, (T0 a, T1 b),
>> SHORT_FUNCTION(T1, bar, (T3 a),
>> SHORT_FUNCTION(T2, baz, (T4 a), a.baz)
>> auto f = foo(_1, bar(_2)) + baz(3);
>> I might as well write:
>> SHORT_FUNCTION(T2, f, (T0 a, T3 b, T4 c), + c.baz)
>> Note I don't even have to specify T1 here.
>> I could have written the expression as this though (not sure if I
>> remember the right syntax):
>> SHORT_FUNCTION(T2, foo, (T0 a, T1 b),
>> auto f = foo(_1, (_2->*&T2::bar)()) + (_3->*&T3::baz)();
>> but not only is that verbose, I still need to define a foo lazy function
>> because T0::foo could be overloaded (casting to select the right overload
>> is even more horrible than the ->* syntax).
>> Now, let's consider another case, I want to do + c.baz,
>> but with a, b, and c taken from the scope, and I don't want to have to
>> specify the types of a, b, and c. I can't do that in Phoenix without
>> defining the foo, bar and baz functions at namespace scope, since they
>> must have a template operator(), which is only allowed at that level. I
>> can, however, do that with no problem with Boost.Local.
> Well, you have seen nothing yet ;-)
A boilerplate macro for that would be a very welcome contribution...

Let's start to concentrate on more important things right now, OK?
We all know that Boost.Phoenix has certain limitations and drawbacks, the
problem you, Mathias, described above is one of them.

> Regards,

Boost list run by bdawes at, gregod at, cpdaniel at, john at