Boost logo

Boost :

Subject: Re: [boost] Yap's formal review is starting now!
From: Brook Milligan (brook_at_[hidden])
Date: 2018-02-15 18:41:29


> On Feb 14, 2018, at 2:00 PM, Zach Laine via Boost <boost_at_[hidden]> 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 <boost/yap/algorithm.hpp>

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<minimal_expr>(number{}));
  return 0;
}


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