boostorg / yap

A C++14-and-later expression template library
https://boostorg.github.io/yap
Boost Software License 1.0
108 stars 28 forks source link

Consider adding transform_evaluate() #63

Closed tzlaine closed 6 years ago

tzlaine commented 6 years ago

What does evaluate_with_context now do? Let's say expr is "a + b". Does the context only apply to the evaluation of a and b as terminals, or does it apply to the plus operation as well?

It applies to the plus operation first. If the context has a handler for plus, then it's up to the context to handle recursion. If it does not, then it becomes evaluate_with_context(a, ctx, x...)

Are such applications of the context conditional? How does the reader quickly grasp what the evaluate_with_context() call does? This seems like really muddy code to me. If you have something else in mind, please provide more detail -- I may of course be misunderstanding you.

My idea is that it would behave exactly like transform, except that the default behavior for nodes that are not handled by the context is to evaluate the operators instead of building a new expression.

Ah, I think I get it now. This is really a transform_evaluate() then? If so, that does sound useful.

tzlaine commented 6 years ago

Mooted by recent API changes.

ldionne commented 6 years ago

Can you explain exactly how the functionality of transform_evaluate can now be achieved? Looked at the new documentation but can't figure it out easily.

tzlaine commented 6 years ago

Sure. transform_evaluate(xform) is the same as transform(xform, evaluation()), now that multiple transform objects can be passed to transform().

ldionne commented 6 years ago

Ahhhh, I see.