|
Proto : |
Subject: Re: [proto] Recursive functions in a mini language
From: Manjunath Kudlur (keveman_at_[hidden])
Date: 2010-08-06 20:21:58
> Careful here. You want BOOST_PROTO_AUTO, or else put these things in a
> domain defined such that intermediate expressions are not held by
> reference. Or else, make declare_module an instance of a type with an
> overloaded operator[] that deep-copies it's rhs to avoid all lifetime
> issues. Proto expression templates are make entirely of temporary
> object. Here be dragons.
I didn't think about lifetime issues yet, though I meant to use
BOOST_PROTO_AUTO.
> Let me understand. Your goal is to have something like spirit subrules,
> except the subrules are like ordinary functions, and the functions
> should be invokable by name, is that right? Spirit subrules are neat and
> tidy and efficient because they are hidden away inside a grammar. But
> that's not your case. Hence the need for the module and the operator->*.
> Did I get that right?
>
Yes. I know with Spirit subrules, one only exposes the top level rule
and the auxiliary rules are hidden inside the grammar. Here, my goal
is to provide the user with a mechanism to define a set of mutually
recursive functions, and he should be able to "call" any of the
functions. He has to do module->*func(...) and cannot do just
func(...) because the definitions of functions are contained in the
module.
Manjunath
> Eric Niebler
> BoostPro Computing
> http://www.boostpro.com
> _______________________________________________
> proto mailing list
> proto_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/proto
>
Proto list run by eric at boostpro.com