Subject: Re: [boost] New libraries implementing C++11 features in C++03
From: Lorenzo Caminiti (lorcaminiti_at_[hidden])
Date: 2011-11-25 07:59:00
On Fri, Nov 25, 2011 at 7:24 AM, Joel de Guzman
> On 11/25/2011 7:16 PM, Christopher Jefferson wrote:
>> You seem simply unwilling to accept that there are people who refuse to use Pheonix,
>> and libraries built on it because:
>> 1) It leads to horribly large compile times.
>> 2) Error messages. I know you hate this, so let me write out my opinion one last time.
>> Phoenix leads to error messages which:
>> * On the compilers I commonly use - I can't change this, there aren't that many
>> compilers around.
>> * Are very, very large
>> * and require different skills to read and understand than any other library.
> Ok, let's put that to a test.
> 1) You are using a phoenix function
> 2) Your lambda is solely for capturing locals, and should be
> the basic counterpart of how you do it using Locals (i.e.
> no fancy phoenix expressions -- we restrict ourself to
> simple capturing of locals).
> Here's a sample code:
And the example can be modified to use templates so not to explicitly
specify the bound types:
template<typename B, typename L, typename S>
void plus4(int i, B b, L l, S s)
std::cout << (i + l) << std::endl;
BOOST_PHOENIX_ADAPT_FUNCTION(void, plus4, impl::plus4, 4)
bool b = true;
long l = 999;
std::string const s = "Hello";
std::for_each(vec.begin(), vec.end(), plus4(_1, b, l, s));
As I said before, what it is missing here is that plus4 is not defined
at local scope so it is not a local function. However, I recognize and
understand that in your opinion there is no need to declare functions
at local scope using statement syntax (in your opinion that can be
done outside the function scope like in the example above).
> I set it up so you can disable phoenix and test the net time.
> Here's what I get:
> with Phoenix:
> start time: 19:44:57.73
> end time: 19:44:59.69
> : 2.0 secs
> without Phoenix:
> start time: 19:44:29.07
> end time: 19:44:30.81
> : 1.7 secs
> Now, how about error messages. Here's the lambda part:
> std::for_each(vec.begin(), vec.end(), plus4(_1, b, l, s));
> You'd have to be absurdly dumb to get that wrong! A more
> realistic scenario is a mistake in the function body itself.
> In which case (try it out), you'll get the same errors as
> plain-'ole C++.
> 1) Leads to horribly large compile times? Not if you keep your
> phoenix expressions simple.
> 2) Error messages? Again, none if you keep your phoenix
> expressions simple.
> And "simple" is the point. Locals does not have complex
> expressions anyway. The complexity is in the function body.
> THAT is the use case of Locals and THAT is one of the cases
> where phoenix really shines.
> So, gentlemen, please, let's keep the FUD to a minimum.