Boost logo

Proto :

Subject: Re: [proto] proto-11 progress report
From: Eric Niebler (eric_at_[hidden])
Date: 2012-06-25 17:40:47


On 6/25/2012 12:44 PM, Bart Janssens wrote:
> On Sun, Jun 24, 2012 at 1:10 AM, Eric Niebler <eric_at_[hidden]> wrote:
>> Data parameter uses a slot mechanism
>> ====================================
>> In proto today, transforms take 3 parameters: expression, state and
>> data. As you can see from above, transforms in proto-11 take an
>> arbitrary number of parameters. However, that can make it hard to find
>> the piece of data you're looking for. Which position will it be in?
>> Instead, by convention most transforms will still only deal with the
>> usual 3 parameters. However, the data parameter is like a fusion::map:
>> it will have slots that you can access in O(1) by tag.
>
> Intersting! Our current "data" element contains a fusion vector, also
> to enable grouping of strongly typed data. This is a major source of
> complexity in our code, so it will be simpler if we can reuse this
> mechanism.

Yes, the slots mechanism greatly simplifies that kind of code. You can
find a simple lambda library example here:

https://github.com/ericniebler/home/blob/master/src/proto/libs/proto/example/lambda.cpp

Notice how the lambda_eval_ function uses the slots feature to store the
lambda's arguments on line 48, and how the algorithm accesses the values
of those slots on line 36. Formerly, this had to be done with a fusion
vector, as you are doing. This way is much simpler, I think.

I primarily added this feature so that I have a way to implement the
let<> transform I've described here previously. It'll give you a way to
create local variables within a transform. The current let "stack frame"
will use one of these slots.

-- 
Eric Niebler
BoostPro Computing
http://www.boostpro.com



Proto list run by eric at boostpro.com