|
Boost : |
Subject: Re: [boost] phoenix::bind
From: Peter Dimov (pdimov_at_[hidden])
Date: 2008-09-30 07:35:17
Joel de Guzman:
> Alright, let's put it to a vote then. Here's my vote:
>
> Capture expressions by value: +1
> Capture special objects by ref
> (e.g. cout, endl, arrays): +1
This is not that different from Lambda, except that it has
Capture left side of = and @= by ref: +0.5
>> Const propagation is less of an issue in Phoenix because it has true
>> local variables. With boost::bind and a suitably defined f, one can do
>>
>> boost::bind( f, 0, 0, _1 )
>>
>> to approximate a lambda with two local variables, initially 0, and one
>> argument.
>
> That's a nice trick! That can be quite useful on certain occasions.
If you manage to include both Phoenix and boost::bind, you can do a
generator function that returns 1, 2, 3... with:
boost::bind<int>( ++arg1, 0 )
Of course if you have Phoenix you should be able to do the same with
lambda( _a = 0 )[ ++_a ]
but it doesn't seem to work. Maybe I'm doing something wrong. :-)
>> Phoenix doesn't need such tricks. But the question needs to be
>> considered, and a balance has to be struck.
>
> What do you think would be a good balance?
I'm not sure yet. I like the const propagation feature of boost::bind, but I
can't say how it'd work in the larger Phoenix context, and whether it
wouldn't prove too error-prone for casual use.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk