
AMDG Markus Werle wrote:
Steven Watanabe <watanabesj <at> gmail.com> writes:
Markus Werle wrote: [...]
OTOH the third template argument contains redundant information: The docs say: "Proto expression nodes are valid Fusion random-access sequences of their children nodes." So the information about the number of arguments is accessible via some size<T>::type metafunction e.g. depending on
result_of::distance<result_of::begin<S>::type result_of::end<S>::type>::type?
[...] I believe that it is needed to allow partial specialization. expr<Tag, Args, 0>, expr<Tag, Args, 1>, ...
Sorry if I do not get that one.
The definition of expr is something like: template<class Tag, class Args, int Arity = Args::arity> struct expr; template<class Tag, class Args> struct expr<Tag, Args, 0> { typename Args::arg0 arg0; }; template<class Tag, class Args> struct expr<Tag, Args, 1> { typename Args::arg0 arg0; }; template<class Tag, class Args> struct expr<Tag, Args, 2> { typename Args::arg0 arg0; typename Args::arg1 arg1; }; ...
And users don't need to care about it, since it has a default.
"User" is a very ambiguous word for proto. Actually most "users" of proto will be "library writers" seeking to boost (sic!) their productivity. So even the nitty-gritty details matter. I reject any "do-not-mind-it's-only-deep-inside" arguments here. Everybody writing a compile time algorithm acting on proto structures for whatever reason will be affected by this "detail" and the implications might only become clear later, when somebody is in need to do some compile-time-magic.
From Daixtrose I know that the number of template arguments can be reciprocal to readability, maintainability and extensibility.
You can (and should) write expr<terminal_tag, args0<int> > rather than expr<terminal_tag, args0<int>, 0>. Library writers are not somehow special in this respect. When I said "user" I meant anyone who is not the author or maintainer of proto.The only problems that I can see are that mpl::apply<expr<mpl::_, mpl::_>, terminal_tag, args0<int> > won't work and that mpl::quote2<expr> will fail. In Christ, Steven Watanabe