Boost logo

Proto :

Subject: Re: [proto] Thoughts on traversing proto expressions and reusing grammar
From: Eric Niebler (eric_at_[hidden])
Date: 2010-10-21 14:47:19


On 10/20/2010 11:41 PM, Thomas Heller wrote:
> On Thu, Oct 21, 2010 at 7:50 AM, Thomas Heller
> <thom.heller_at_[hidden]> wrote:
>> On Thursday 21 October 2010 05:11:49 Eric Niebler wrote:
>>> On 10/20/2010 7:49 AM, Thomas Heller wrote:
> <snip>
>>>> Here it goes:
>>>> namespace detail
>>>> {
>>>> template <
>>>> typename Grammar, typename Visitor, typename IsRule = void>
>>>> struct algorithm_case
>>>> : Grammar
>>>> {};
>>>
>>> Why inherit from Grammar here instead of:
>>> : proto::when<
>>> Grammar
>>> , typename Visitor::template visit<Grammar>
>>> >
>>>
>>> ?
>>
>> Because I wanted to have an "escape" point. There might be some valid
>> usecase, that does not want to dispatch to the Visitor/Actions. This is btw
>> the reason i didn't reuse or_, but introduced the rules template. To
>> distinguish between: 1) "regular" proto grammars --> no dispatch 2) the
>> rules, which do the dispatch.
>
> Ok ... after rereading your mini phoenix you solve that problem with
> default_actions.
> Very neat as well!

Right. In fact, I don't think it's necessary or desirable to let the
"Grammar" parameter to "algorithm_case" be anything that isn't an
instantiation of "rules". That is, you have algorithm_case and
algorithm_case_rule. Nuke algorithm_case and rename algorithm_case_rule
to algorithm_case. Also, nuke "rule". The variadic "rules" is all that's
needed. A few orthogonal features are better than lots needless
distracting flexibility.

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

Proto list run by eric at boostpro.com