Boost logo

Boost :

From: Eric Niebler (eric_at_[hidden])
Date: 2007-05-25 21:01:14


Maurizio Vitale wrote:
> Eric Niebler <eric_at_[hidden]> writes:
>
>> Maurizio Vitale wrote:
>>> What about introducing a macro:
>>>
>>> #define BOOST_PROTO_WRAP(DOMAIN,EXPRESSION) \
> [cut]
>> I agree, this part of proto isn't as nice as it could be. I've
>> considered making the expression generator a template parameter to the
>> proto::domain, something like:
>>
>> struct my_domain
>> : proto::domain< struct my_grammar, struct my_generator >
>> {};
>>
>> This way, you wouldn't have to open proto's namespace to specialize
>> proto::generate. I haven't thought too hard about it, though. I do know
>> that I would like to avoid macros in proto's interface as much as possible.
>
> Instead of the macro I was thinking about defining the generator inside my_domain.
> If the code is really always the same, it is not even necessary to define the complete
> generator, just the expression to wrap around proto expressions.
> I think where the wrapper is used, my_context is available.
>
> If this is doable it would encapsulate the wrapper inside the domain, which is where it belongs.

This is now implemented. Proto::generate<> is gone. You now specify the
expression generator as a template parameter to proto::domain. NOTE: the
generator parameter comes first! The (optional) grammar parameter is now
second.

Also, there is a helper for adapting an expression wrapper to a
generator. Given some expression wrapper:

   struct mydomain;

   template<typename Expr>
   struct myexpr : proto::extends<Expr, myexpr<Expr>, mydomain>
   ...

You can specify the generator with:

   struct mydomain
     : proto::domain< proto::generator<myexpr> >
   {};

This change should loudly break any existing code that uses generators.
Sorry for that.

-- 
Eric Niebler
Boost Consulting
www.boost-consulting.com

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk