Boost logo

Proto :

Subject: Re: [proto] : Proto transform with state
From: Eric Niebler (eric_at_[hidden])
Date: 2010-11-18 13:00:03


On 11/18/2010 6:09 AM, Thomas Heller wrote:
> Ok ... I implemented let!

You've been busy. :-)

> Here goes the renumbering example:
> http://codepad.org/K0TZamPb
>
> The change is in line 296 rendering RenumberFun to:
> struct RenumberFun
> : proto::fold<
> _
> , make_pair(fusion::vector<>(), proto::_state)
> , let<
> _a(Renumber(_, second(proto::_state)))
> , make_pair(
> push_back(
> first(proto::_state)
> , first(_a)
> )
> , type_of<second(_a) >
> )
> >
> >
> {};
>
> The implementation of let actually was quite easy ... here is how it works:
>
> let<Locals, Transform> is a transform taking definitions of local variables and
> the transform these locals will get applied to.
> A local definition is in the form of: LocalName(LocalTransform)
> If the specified transform has LocalName embedded, it will get replaced by
> LocalTransform.

Unfortunately, this doesn't actually solve the reevaluation problem ...
it just hides it. If "_a" gets replaced eagerly everywhere with
"Renumber(_, second(proto::_state))", then that transform will actually
get run every time. What I want is a way to evaluate the transform,
store the result in a temporary, and have "_a" refer to that temporary.
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.

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

Proto list run by eric at boostpro.com