On Thu, Feb 15, 2018 at 12:41 PM, Brook Milligan
On Feb 14, 2018, at 2:00 PM, Zach Laine via Boost
wrote: Actually, I think you need to define what an expression is in this context. In my book, expressions are not just made of operators, but can also include function calls. However, the implicit impression I get from the YAP documentation is that you only consider expressions based on operators, and not functions. For instance, I consider std::sqrt(x) an expression. However, looking at expr_kind (https://tzlaine.github.io/ yap/doc/html/boost/yap/expr_kind.html) it seems that this kind expression is not supported, (but it could be as a Transform).
That's supported. std::sqrt(x) would need to be Yap-ified if x is not already Yap expression, perhaps by making a sqrt Yap terminal, or by calling std::sqrt on a Yap expression. Assuming x is a Yap expression, the entire expression "std::sqrt(x)" is a Yap expression whose kind is expr_kind::call. This underscores the need to make this more explicit in the docs, though. *TODO*
I'm confused by this claim. You seem to be suggesting that STL math functions somehow can evaluate Yap expressions? How can that be?
The following code, which I believe implements what you are suggesting, does not compile for me.
Yes, there needs to be better documentation of the use of functions and the call operator kind of expression.
Cheers, Brook
#include <cmath> #include
template < boost::yap::expr_kind Kind, typename Tuple > struct minimal_expr { static const boost::yap::expr_kind kind = Kind; Tuple elements; };
class number {};
int main () { using boost::yap::make_terminal; std::sqrt(make_terminal
(number{})); return 0; }
That's right. But try making `std::sqrt` the terminal that you chain
everything off of. As long as the expression template you use has a call
operator, it Just Works. For instance, our favorite whipping boy
expression<> has one. This compiles, I promise:
template <typename T>
using term = boost::yap::terminal
yap_expr = term