Subject: Re: [boost] New libraries implementing C++11 features in C++03
From: Christopher Jefferson (chris_at_[hidden])
Date: 2011-11-25 09:58:57
On 25 Nov 2011, at 14:40, Joel de Guzman wrote:
> On 11/25/2011 10:26 PM, Christopher Jefferson wrote:
>> On 25 Nov 2011, at 14:04, Joel de Guzman wrote:
>>> On 11/25/2011 9:58 PM, Joel de Guzman wrote:
>>>>> In the past I tried turning this into phoenix code, and failed. I'd be genuinely
>>>> interested to know what it would look like as a phoenix function.
>>>> Here's the phoenix functions rendition of that:
>>> Oops, T1 should be a reference. One more try:
>> Thank you, but I was thinking more doing the whole thing in-line (else, I would just
>> write a function object, much like you did, without the phoenix), or use std::bind.
>> Of course, it might be the case that writing that inline is just more pain than it is
>> worth. Certainly it would get a bit long hanging off a for-each!
> Well, the point of the exercise is to use "statement syntax",
> just as you did using Locals. By doing so, you lessen the chance
> of having "outrageous error messages" and minimize compile time.
Then, there is a misunderstanding on the purpose of boost::local (in my opinion), which I apologise for not making clear!
The reason I would boost::local is the same as C++11 lamdas, to be able to declare (small) functions at the point where they are used, rather than out-of-line. Of course, in my very reduced example, the function may as well have been declared out-of-line, as the function is so short.
Certainly if we remove from boost::local the advantage of declaring new functions in the middle of existing functions, then it has almost no purpose in existing. It is these larger functions where life gets painful with phoenix.
So, in my opinion, boost's local place for existence is for functions which:
* We don't want to define out-of-line
* Which are slightly too big for comfortable phoenixing (so not just _1 + 1, or cout << _1)
* For people can't assume a C++11 compiler with lambdas.
Is that a big enough area? I'm not positive.
It seems much of this discussion is turning into what boost 'should be'. That's an interesting argument which might be better had without boost::local hanging around. One of the biggest problems with C++ (in my opinion) is that it is a pain to distribute and use libraries, as there is no nice library package manager, so boost is currently the closest thing there is to a C++ package library. A better package manager might alleviate that pressure, to allow boost to become "whatever it wants to be".
Boost list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk