Writing expressions that pass in all inputs for performance reasons is somewhat cumbersome. For example, it's much nicer to write:
Execute ( () => A + B )
Execute ( this, t => t.A + t.B )
Obviously this is a very simple example, but it's unfortunate that consumers of the library have to be fully aware of this significant performance issue.
In our system, we have a "Getter" method that lives in a base class and sets up the Obtics expressions. In this, we would have the opportunity to transform an expression like the first form into an expression like the second form. All
we'd need to do is replace all references to "this" with a lambda parameter and then add a lambda parameter to the expression. Can anyone comment on the easiest way to walk the lambda expression tree to do this transformation? Is there
perhaps a way to use Obtics framework code as a visitor system for performing this transformation?
I haven't thought it through, but perhaps a system that replaces variables with parameters would be useful in a general case for Obtics. Upon compilation, it could strip the fixed values and make them into parameters, thereby providing greater opportunity
for caching. Obviously there would be some cost for the expression modification, but I imagine it would be significantly less than the cost of compilation.
Thoughts are welcome. :)