
On 03/03/08 15:51, Eric Niebler wrote:
Larry Evans wrote:
On 03/03/08 00:21, Eric Niebler wrote:
Larry Evans wrote:
If the template arguments are grammars then shift_right<L,R>::type is not an expression type.
Correct, it's a grammar type.
AFAICT, it's of no use.
That's not true. The fact that shift_right<L,R>::type creates expressions when L and R are expressions, and grammars when L and R are grammars,
Are you saying shift_right<L,R>::type is a grammar when L and R are grammars
Yes! :-)
Ah! Not what I expected. The fog around my brain is thickening :(
or did you mean shift_right<L,R> is a grammar when L and R are grammars?
That is also true. This is a short-hand, provided for convenience.
shift_right<L,R>::type is *very* simple. It is expr<tag::shift_right, args2<L, R> >. Always.
Unexpected again. I jumped to the conclusion that expr was for expressions, not grammars. So then is shift_right<L,R>::type, when L and R are grammars, the same as shift_right<L,R>?
It's just a 2-element container and a tag. If L and R are expressions, it is an expression. If they're grammars, it is a grammar, suitable for use as the second template parameter to proto::matches. It is simple, IMO, and leads to a very straightforward implementation of proto::matches<>. See, for instance, how the behavior of proto::matches<> is specified in terms of expr<> instantiations:
<http://boost-sandbox.sourceforge.net/libs/proto/doc/html/boost/proto/result_of/matches.html> Ah ha! The fog begins to lift. I should have read that. I apologize. Maybe if near the beginning of the documentation the concepts of expressions, grammars, and transforms were introduced, and then mention that a grammar was a type of expression... or at least was formed with the same template as an expression... Hmm.. Getting confused again. How can one distinguish a grammar from an expression if both are formed from the same template, i.e. the expr template? Maybe by starting from the base case, the terminal template? IOW, is the following: base_case) For any type T: terminal<T> is a grammar type. terminal<T>::type is an expression type. inductive_case) If T0,T1,...,Tn are all grammar types, and Tag is an n-ary tag, then expr<Tag,T0,T2,...,Tn> is a grammar type. If T0,T1,...,Tn are all expression types, and Tag is an n-ary tag, then expr<Tag,T0,T,...,Tn> is an expression type. Otherwise, expr<Tag,T0,T1,...,Tn> is meaningless (a.k.a. undefined). a correct description of how to distinguish a grammar type from an expression type? [snip]
What I can agree with is the following: the documentation currently doesn't say what right_shift<L,R>::type means when L and R are grammars. That is an oversight, and I'll fix it.
Thanks.