Boost logo

Proto :

Subject: Re: [proto] : Proto transform with state
From: Thomas Heller (thom.heller_at_[hidden])
Date: 2010-12-06 16:50:20

Eric Niebler wrote:

> On 11/18/2010 3:31 PM, Eric Niebler wrote:
>> On 11/18/2010 1:45 PM, Thomas Heller wrote:
>>> Eric Niebler <eric_at_...> writes:
>>>> It's REALLY hard. The let context needs to be bundled with the Expr,
>>>> State, or Data parameters somehow, but in a way that's transparent. I
>>>> don't actually know if it's possible.
>>> Very hard ... yeah. I am thinking that we can maybe save these variables
>>> in the transform?
>> I'm thinking we just stuff it into the Data parameter. We have a
>> let_scope template that is effectively a pair containing:
>> 1. The user's original Data, and
>> 2. A Fusion map from local variables (_a) to values.
>> The let transform evaluates the bindings and stores the result in the
>> let_scope's Fusion map alongside the user's Data. We pass the let_scope
>> as the new Data parameter. _a is itself a transform that looks up the
>> value in Data's Fusion map. The proto::_data transform is changed to be
>> aware of let_scope and return only the original user's Data. This can
>> work. We also need to be sure not to break the new
>> proto::external_transform.
>> The problems with this approach as I see it:
>> 1. It's not completely transparent. Custom primitive transforms will see
>> that the Data parameter has been monkeyed with.
>> 2. Local variables like _a are not lexically scoped. They are, in fact,
>> dynamically scoped. That is, you can access _a outside of a let<>
>> clause, as long as you've been called from within a let clause.
>> Might be worth it. But as there's no pressing need, I'm content to let
>> this simmer. Maybe we can think of something better.
> I played with the let transform idea over the weekend. It *may* be
> possible to accomplish without the two problems I described above. See
> the attached let transform (needs latest Proto trunk). I'm also
> attaching the Renumber example, reworked to use let.
> This code is NOT ready for prime time. I'm not convinced it behaves
> sensibly in all cases. I'm only posting it as a curiosity. You're insane
> if you use this in production code. Etc, etc.

Without having looked at it too much ... this looks a lot like the
environment in phoenix. Maybe this helps in cleaning it out a bit.

Proto list run by eric at